Browse Source
This brings proper theming to these screens (fixes #521) and finally solves the issue of the title base now showing up in sub-screens (#491 and many, many others)pull/565/head
Eric Kok
4 years ago
40 changed files with 991 additions and 817 deletions
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
package org.transdroid.core.gui.settings; |
||||
|
||||
import android.app.Activity; |
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.media.RingtoneManager; |
||||
import android.net.Uri; |
||||
import android.provider.Settings; |
||||
import android.util.AttributeSet; |
||||
|
||||
import androidx.preference.Preference; |
||||
|
||||
@SuppressWarnings("unused") // Constructors for XML inflation
|
||||
public class RingtonePreference extends Preference { |
||||
|
||||
private static final int REQUEST_RINGTONE = 0; |
||||
|
||||
public RingtonePreference(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public RingtonePreference(Context context, AttributeSet attrs) { |
||||
super(context, attrs); |
||||
} |
||||
|
||||
public RingtonePreference(Context context, AttributeSet attrs, int defStyleAttr) { |
||||
super(context, attrs, defStyleAttr); |
||||
} |
||||
|
||||
public RingtonePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
||||
super(context, attrs, defStyleAttr, defStyleRes); |
||||
} |
||||
|
||||
@Override |
||||
protected void onClick() { |
||||
if (!(getContext() instanceof Activity)) { |
||||
return; |
||||
} |
||||
|
||||
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); |
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); |
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); |
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true); |
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, Settings.System.DEFAULT_NOTIFICATION_URI); |
||||
|
||||
String existingValue = getSharedPreferences().getString(getKey(), null); |
||||
if (existingValue != null) { |
||||
if (existingValue.isEmpty()) { |
||||
// Select "Silent"
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); |
||||
} else { |
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(existingValue)); |
||||
} |
||||
} else { |
||||
// No ringtone has been selected, set to the default
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Settings.System.DEFAULT_NOTIFICATION_URI); |
||||
} |
||||
|
||||
((Activity) getContext()).startActivityForResult(intent, REQUEST_RINGTONE); |
||||
} |
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
||||
if (requestCode == REQUEST_RINGTONE && resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { |
||||
Uri ringtone = (Uri) data.getExtras().get(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); |
||||
getSharedPreferences().edit().putString(getKey(), ringtone == null? "": ringtone.toString()).apply(); |
||||
} |
||||
} |
||||
} |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- File created by the Android Action Bar Style Generator |
||||
|
||||
Copyright (C) 2012 readyState Software Ltd |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
||||
--> |
||||
|
||||
<resources> |
||||
|
||||
<style name="Theme.Transdroid.Auto" parent="Theme.AppCompat.DayNight.NoActionBar"> |
||||
<item name="drawer_background">@color/transdroid_background</item> |
||||
<item name="activatable_background">@drawable/activatable_background</item> |
||||
|
||||
<item name="colorPrimary">@color/green</item> |
||||
<item name="colorPrimaryDark">@color/green_dark</item> |
||||
<item name="windowActionModeOverlay">true</item> |
||||
<item name="actionModeBackground">@color/grey</item> |
||||
<item name="android:textViewStyle">@style/DefaultTextView</item> |
||||
<item name="android:windowBackground">@color/transdroid_background</item> |
||||
<item name="loading_progress">@drawable/loading_progress</item> |
||||
<item name="text_bright">@color/transdroid_text_bright</item> |
||||
<item name="text_actionbar">@color/transdroid_text_actionbar</item> |
||||
<item name="text_actionbar_secondary">@color/transdroid_text_actionbar</item> |
||||
</style> |
||||
|
||||
</resources> |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- File created by the Android Action Bar Style Generator |
||||
|
||||
Copyright (C) 2011 The Android Open Source Project |
||||
Copyright (C) 2012 readyState Software Ltd |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
||||
--> |
||||
|
||||
<resources> |
||||
|
||||
<style name="Theme.Transdroid.Auto" parent="Theme.AppCompat.DayNight.NoActionBar"> |
||||
<item name="drawer_background">@color/transdroid_background</item> |
||||
<item name="activatable_background">@drawable/activatable_background</item> |
||||
|
||||
<item name="colorPrimary">@color/green</item> |
||||
<item name="colorPrimaryDark">@color/green_dark</item> |
||||
<item name="colorControlHighlight">@color/green_light</item> |
||||
<item name="colorAccent">@color/green_light</item> |
||||
<item name="windowActionModeOverlay">true</item> |
||||
<item name="actionModeBackground">@color/grey</item> |
||||
<item name="android:textViewStyle">@style/DefaultTextView</item> |
||||
<item name="android:windowBackground">@color/transdroid_background</item> |
||||
<item name="loading_progress">@drawable/loading_progress</item> |
||||
<item name="text_bright">@color/transdroid_text_bright</item> |
||||
<item name="text_actionbar">@color/transdroid_text_actionbar</item> |
||||
<item name="text_actionbar_secondary">@color/transdroid_text_actionbar</item> |
||||
</style> |
||||
|
||||
</resources> |
Loading…
Reference in new issue