Updated on 2026-08-14
This commit is contained in:
parent
ba7fa704be
commit
318be959b7
13 changed files with 534 additions and 19 deletions
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
|
|
@ -56,4 +56,4 @@ dependencies {
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher"
|
android:roundIcon="@mipmap/ic_launcher"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="com.tangem.LogFileProvider"
|
android:name="com.tangem.LogFileProvider"
|
||||||
android:authorities="com.tangem.LogFileProvider"
|
android:authorities="com.tangem.LogFileProvider"
|
||||||
|
|
@ -38,10 +37,10 @@
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.MainActivity"
|
android:name="com.tangem.presentation.activity.MainActivity"
|
||||||
android:label="@string/title_activity_main"
|
android:label="@string/title_activity_main"
|
||||||
|
|
@ -50,7 +49,9 @@
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
|
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:host="www.tangem.com"
|
android:host="www.tangem.com"
|
||||||
android:scheme="http"/>
|
android:scheme="http"/>
|
||||||
|
|
@ -63,87 +64,75 @@
|
||||||
android:name="android.nfc.action.TECH_DISCOVERED"
|
android:name="android.nfc.action.TECH_DISCOVERED"
|
||||||
android:resource="@xml/nfc_tech_filter"/>
|
android:resource="@xml/nfc_tech_filter"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.RequestPINActivity"
|
android:name="com.tangem.presentation.activity.RequestPINActivity"
|
||||||
android:label="@string/title_activity_main"
|
android:label="@string/title_activity_main"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.EmptyWalletActivity"
|
android:name="com.tangem.presentation.activity.EmptyWalletActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.SelectBlockchainActivity"
|
android:name="com.tangem.presentation.activity.SelectBlockchainActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.SavePINActivity"
|
android:name="com.tangem.presentation.activity.SavePINActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.CardInfoActivity"
|
android:name="com.tangem.presentation.activity.CardInfoActivity"
|
||||||
android:label="@string/title_activity_card_info"
|
android:label="@string/title_activity_card_info"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.LoadedWalletActivity"
|
android:name="com.tangem.presentation.activity.LoadedWalletActivity"
|
||||||
android:label="@string/title_activity_loaded_wallet"
|
android:label="@string/title_activity_loaded_wallet"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.VerifyCardActivity"
|
android:name="com.tangem.presentation.activity.VerifyCardActivity"
|
||||||
android:label="@string/title_activity_loaded_wallet"
|
android:label="@string/title_activity_loaded_wallet"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.CreateNewWalletActivity"
|
android:name="com.tangem.presentation.activity.CreateNewWalletActivity"
|
||||||
android:label="@string/title_activity_main"
|
android:label="@string/title_activity_main"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.PreparePaymentActivity"
|
android:name="com.tangem.presentation.activity.PreparePaymentActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.ConfirmPaymentActivity"
|
android:name="com.tangem.presentation.activity.ConfirmPaymentActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.SignPaymentActivity"
|
android:name="com.tangem.presentation.activity.SignPaymentActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.PurgeActivity"
|
android:name="com.tangem.presentation.activity.PurgeActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.SwapPINActivity"
|
android:name="com.tangem.presentation.activity.SwapPINActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.QRScanActivity"
|
android:name="com.tangem.presentation.activity.QRScanActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.tangem.presentation.activity.SendTransactionActivity"
|
android:name="com.tangem.presentation.activity.SendTransactionActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
<activity
|
||||||
|
android:name="com.tangem.presentation.activity.SettingsFeatureActivity"
|
||||||
|
android:label="@string/title_activity_settings_feature">
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.tangem.presentation.activity
|
||||||
|
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.preference.PreferenceActivity
|
||||||
|
import android.support.annotation.LayoutRes
|
||||||
|
import android.support.v7.app.ActionBar
|
||||||
|
import android.support.v7.app.AppCompatDelegate
|
||||||
|
import android.support.v7.widget.Toolbar
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [android.preference.PreferenceActivity] which implements and proxies the necessary calls
|
||||||
|
* to be used with AppCompat.
|
||||||
|
*/
|
||||||
|
abstract class AppCompatPreferenceActivity : PreferenceActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
delegate.installViewFactory()
|
||||||
|
delegate.onCreate(savedInstanceState)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onPostCreate(savedInstanceState)
|
||||||
|
delegate.onPostCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
val supportActionBar: ActionBar?
|
||||||
|
get() = delegate.supportActionBar
|
||||||
|
|
||||||
|
fun setSupportActionBar(toolbar: Toolbar?) {
|
||||||
|
delegate.setSupportActionBar(toolbar)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getMenuInflater(): MenuInflater {
|
||||||
|
return delegate.menuInflater
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setContentView(@LayoutRes layoutResID: Int) {
|
||||||
|
delegate.setContentView(layoutResID)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setContentView(view: View) {
|
||||||
|
delegate.setContentView(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setContentView(view: View, params: ViewGroup.LayoutParams) {
|
||||||
|
delegate.setContentView(view, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addContentView(view: View, params: ViewGroup.LayoutParams) {
|
||||||
|
delegate.addContentView(view, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPostResume() {
|
||||||
|
super.onPostResume()
|
||||||
|
delegate.onPostResume()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTitleChanged(title: CharSequence, color: Int) {
|
||||||
|
super.onTitleChanged(title, color)
|
||||||
|
delegate.setTitle(title)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
super.onConfigurationChanged(newConfig)
|
||||||
|
delegate.onConfigurationChanged(newConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
delegate.onStop()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
delegate.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun invalidateOptionsMenu() {
|
||||||
|
delegate.invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val delegate: AppCompatDelegate by lazy {
|
||||||
|
AppCompatDelegate.create(this, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
package com.tangem.presentation.activity
|
||||||
|
|
||||||
|
import android.annotation.TargetApi
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.media.RingtoneManager
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.preference.*
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.view.MenuItem
|
||||||
|
import com.tangem.wallet.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [PreferenceActivity] that presents a set of application settings. On
|
||||||
|
* handset devices, settings are presented as a single list. On tablets,
|
||||||
|
* settings are split by category, with category headers shown to the left of
|
||||||
|
* the list of settings.
|
||||||
|
*
|
||||||
|
* See [Android Design: Settings](http://developer.android.com/design/patterns/settings.html)
|
||||||
|
* for design guidelines and the [Settings API Guide](http://developer.android.com/guide/topics/ui/settings.html)
|
||||||
|
* for more information on developing a Settings UI.
|
||||||
|
*/
|
||||||
|
class SettingsFeatureActivity : AppCompatPreferenceActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setupActionBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the [android.app.ActionBar], if the API is available.
|
||||||
|
*/
|
||||||
|
private fun setupActionBar() {
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
override fun onIsMultiPane(): Boolean {
|
||||||
|
return isXLargeTablet(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
override fun onBuildHeaders(target: List<PreferenceActivity.Header>) {
|
||||||
|
loadHeadersFromResource(R.xml.pref_headers, target)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method stops fragment injection in malicious applications.
|
||||||
|
* Make sure to deny any unknown fragments here.
|
||||||
|
*/
|
||||||
|
override fun isValidFragment(fragmentName: String): Boolean {
|
||||||
|
return PreferenceFragment::class.java.name == fragmentName
|
||||||
|
|| GeneralPreferenceFragment::class.java.name == fragmentName
|
||||||
|
|| DataSyncPreferenceFragment::class.java.name == fragmentName
|
||||||
|
|| NotificationPreferenceFragment::class.java.name == fragmentName
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fragment shows general preferences only. It is used when the
|
||||||
|
* activity is showing a two-pane settings UI.
|
||||||
|
*/
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
class GeneralPreferenceFragment : PreferenceFragment() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
addPreferencesFromResource(R.xml.pref_general)
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
||||||
|
// to their values. When their values change, their summaries are
|
||||||
|
// updated to reflect the new value, per the Android Design
|
||||||
|
// guidelines.
|
||||||
|
bindPreferenceSummaryToValue(findPreference("example_text"))
|
||||||
|
bindPreferenceSummaryToValue(findPreference("example_list"))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
val id = item.itemId
|
||||||
|
if (id == android.R.id.home) {
|
||||||
|
startActivity(Intent(activity, SettingsFeatureActivity::class.java))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fragment shows notification preferences only. It is used when the
|
||||||
|
* activity is showing a two-pane settings UI.
|
||||||
|
*/
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
class NotificationPreferenceFragment : PreferenceFragment() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
addPreferencesFromResource(R.xml.pref_notification)
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
||||||
|
// to their values. When their values change, their summaries are
|
||||||
|
// updated to reflect the new value, per the Android Design
|
||||||
|
// guidelines.
|
||||||
|
bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone"))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
val id = item.itemId
|
||||||
|
if (id == android.R.id.home) {
|
||||||
|
startActivity(Intent(activity, SettingsFeatureActivity::class.java))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This fragment shows data and sync preferences only. It is used when the
|
||||||
|
* activity is showing a two-pane settings UI.
|
||||||
|
*/
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
class DataSyncPreferenceFragment : PreferenceFragment() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
addPreferencesFromResource(R.xml.pref_data_sync)
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
||||||
|
// to their values. When their values change, their summaries are
|
||||||
|
// updated to reflect the new value, per the Android Design
|
||||||
|
// guidelines.
|
||||||
|
bindPreferenceSummaryToValue(findPreference("sync_frequency"))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
val id = item.itemId
|
||||||
|
if (id == android.R.id.home) {
|
||||||
|
startActivity(Intent(activity, SettingsFeatureActivity::class.java))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preference value change listener that updates the preference's summary
|
||||||
|
* to reflect its new value.
|
||||||
|
*/
|
||||||
|
private val sBindPreferenceSummaryToValueListener = Preference.OnPreferenceChangeListener { preference, value ->
|
||||||
|
val stringValue = value.toString()
|
||||||
|
|
||||||
|
if (preference is ListPreference) {
|
||||||
|
// For list preferences, look up the correct display value in
|
||||||
|
// the preference's 'entries' list.
|
||||||
|
val listPreference = preference
|
||||||
|
val index = listPreference.findIndexOfValue(stringValue)
|
||||||
|
|
||||||
|
// Set the summary to reflect the new value.
|
||||||
|
preference.setSummary(
|
||||||
|
if (index >= 0)
|
||||||
|
listPreference.entries[index]
|
||||||
|
else
|
||||||
|
null)
|
||||||
|
|
||||||
|
} else if (preference is RingtonePreference) {
|
||||||
|
// For ringtone preferences, look up the correct display value
|
||||||
|
// using RingtoneManager.
|
||||||
|
if (TextUtils.isEmpty(stringValue)) {
|
||||||
|
// Empty values correspond to 'silent' (no ringtone).
|
||||||
|
preference.setSummary(R.string.pref_ringtone_silent)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val ringtone = RingtoneManager.getRingtone(
|
||||||
|
preference.getContext(), Uri.parse(stringValue))
|
||||||
|
|
||||||
|
if (ringtone == null) {
|
||||||
|
// Clear the summary if there was a lookup error.
|
||||||
|
preference.setSummary(null)
|
||||||
|
} else {
|
||||||
|
// Set the summary to reflect the new ringtone display
|
||||||
|
// name.
|
||||||
|
val name = ringtone.getTitle(preference.getContext())
|
||||||
|
preference.setSummary(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// For all other preferences, set the summary to the value's
|
||||||
|
// simple string representation.
|
||||||
|
preference.summary = stringValue
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to determine if the device has an extra-large screen. For
|
||||||
|
* example, 10" tablets are extra-large.
|
||||||
|
*/
|
||||||
|
private fun isXLargeTablet(context: Context): Boolean {
|
||||||
|
return context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_XLARGE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds a preference's summary to its value. More specifically, when the
|
||||||
|
* preference's value is changed, its summary (line of text below the
|
||||||
|
* preference title) is updated to reflect the value. The summary is also
|
||||||
|
* immediately updated upon calling this method. The exact display format is
|
||||||
|
* dependent on the type of preference.
|
||||||
|
|
||||||
|
* @see .sBindPreferenceSummaryToValueListener
|
||||||
|
*/
|
||||||
|
private fun bindPreferenceSummaryToValue(preference: Preference) {
|
||||||
|
// Set the listener to watch for value changes.
|
||||||
|
preference.onPreferenceChangeListener = sBindPreferenceSummaryToValueListener
|
||||||
|
|
||||||
|
// Trigger the listener immediately with the preference's
|
||||||
|
// current value.
|
||||||
|
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||||
|
PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(preference.context)
|
||||||
|
.getString(preference.key, ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/src/main/res/drawable/ic_info_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_info_black_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11.5,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zm6.5,-6v-5.5c0,-3.07 -2.13,-5.64 -5,-6.32V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5v0.68c-2.87,0.68 -5,3.25 -5,6.32V16l-2,2v1h17v-1l-2,-2z"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_sync_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_sync_black_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -28,5 +28,81 @@
|
||||||
<item>@string/bcEtherium</item>
|
<item>@string/bcEtherium</item>
|
||||||
</array>
|
</array>
|
||||||
<string name="title_activity_loaded_wallet">LoadedWalletActivity</string>
|
<string name="title_activity_loaded_wallet">LoadedWalletActivity</string>
|
||||||
|
<string name="title_activity_settings_feature">Settings</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Strings related to Settings -->
|
||||||
|
|
||||||
|
<!-- Example General settings -->
|
||||||
|
<string name="pref_header_general">General</string>
|
||||||
|
|
||||||
|
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
||||||
|
<string name="pref_description_social_recommendations">Recommendations for people to contact
|
||||||
|
based on your message history
|
||||||
|
</string>
|
||||||
|
|
||||||
|
<string name="pref_title_display_name">Display name</string>
|
||||||
|
<string name="pref_default_display_name">John Smith</string>
|
||||||
|
|
||||||
|
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
|
||||||
|
<string-array name="pref_example_list_titles">
|
||||||
|
<item>Always</item>
|
||||||
|
<item>When possible</item>
|
||||||
|
<item>Never</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_example_list_values">
|
||||||
|
<item>1</item>
|
||||||
|
<item>0</item>
|
||||||
|
<item>-1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Example settings for Data & Sync -->
|
||||||
|
<string name="pref_header_data_sync">Data & sync</string>
|
||||||
|
|
||||||
|
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||||
|
<string-array name="pref_sync_frequency_titles">
|
||||||
|
<item>15 minutes</item>
|
||||||
|
<item>30 minutes</item>
|
||||||
|
<item>1 hour</item>
|
||||||
|
<item>3 hours</item>
|
||||||
|
<item>6 hours</item>
|
||||||
|
<item>Never</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_sync_frequency_values">
|
||||||
|
<item>15</item>
|
||||||
|
<item>30</item>
|
||||||
|
<item>60</item>
|
||||||
|
<item>180</item>
|
||||||
|
<item>360</item>
|
||||||
|
<item>-1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="list_preference_entries">
|
||||||
|
<item>Entry 1</item>
|
||||||
|
<item>Entry 2</item>
|
||||||
|
<item>Entry 3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="list_preference_entry_values">
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="multi_select_list_preference_default_value"/>
|
||||||
|
|
||||||
|
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||||
|
|
||||||
|
<!-- Example settings for Notifications -->
|
||||||
|
<string name="pref_header_notifications">Notifications</string>
|
||||||
|
|
||||||
|
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||||
|
|
||||||
|
<string name="pref_title_ringtone">Ringtone</string>
|
||||||
|
<string name="pref_ringtone_silent">Silent</string>
|
||||||
|
|
||||||
|
<string name="pref_title_vibrate">Vibrate</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
21
app/src/main/res/xml/pref_data_sync.xml
Normal file
21
app/src/main/res/xml/pref_data_sync.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||||
|
dismiss it. -->
|
||||||
|
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="180"
|
||||||
|
android:entries="@array/pref_sync_frequency_titles"
|
||||||
|
android:entryValues="@array/pref_sync_frequency_values"
|
||||||
|
android:key="sync_frequency"
|
||||||
|
android:negativeButtonText="@null"
|
||||||
|
android:positiveButtonText="@null"
|
||||||
|
android:title="@string/pref_title_sync_frequency"/>
|
||||||
|
|
||||||
|
<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
|
||||||
|
design guidelines. -->
|
||||||
|
<Preference android:title="@string/pref_title_system_sync_settings">
|
||||||
|
<intent android:action="android.settings.SYNC_SETTINGS"/>
|
||||||
|
</Preference>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
33
app/src/main/res/xml/pref_general.xml
Normal file
33
app/src/main/res/xml/pref_general.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="example_switch"
|
||||||
|
android:summary="@string/pref_description_social_recommendations"
|
||||||
|
android:title="@string/pref_title_social_recommendations"/>
|
||||||
|
|
||||||
|
<!-- NOTE: EditTextPreference accepts EditText attributes. -->
|
||||||
|
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<EditTextPreference
|
||||||
|
android:capitalize="words"
|
||||||
|
android:defaultValue="@string/pref_default_display_name"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
android:key="example_text"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/pref_title_display_name"/>
|
||||||
|
|
||||||
|
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||||
|
dismiss it. -->
|
||||||
|
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="-1"
|
||||||
|
android:entries="@array/pref_example_list_titles"
|
||||||
|
android:entryValues="@array/pref_example_list_values"
|
||||||
|
android:key="example_list"
|
||||||
|
android:negativeButtonText="@null"
|
||||||
|
android:positiveButtonText="@null"
|
||||||
|
android:title="@string/pref_title_add_friends_to_messages"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
20
app/src/main/res/xml/pref_headers.xml
Normal file
20
app/src/main/res/xml/pref_headers.xml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- These settings headers are only used on tablets. -->
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.tangem.presentation.activity.SettingsFeatureActivity$GeneralPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_info_black_24dp"
|
||||||
|
android:title="@string/pref_header_general"/>
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.tangem.presentation.activity.SettingsFeatureActivity$NotificationPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_notifications_black_24dp"
|
||||||
|
android:title="@string/pref_header_notifications"/>
|
||||||
|
|
||||||
|
<header
|
||||||
|
android:fragment="com.tangem.presentation.activity.SettingsFeatureActivity$DataSyncPreferenceFragment"
|
||||||
|
android:icon="@drawable/ic_sync_black_24dp"
|
||||||
|
android:title="@string/pref_header_data_sync"/>
|
||||||
|
|
||||||
|
</preference-headers>
|
||||||
27
app/src/main/res/xml/pref_notification.xml
Normal file
27
app/src/main/res/xml/pref_notification.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||||
|
when checked/unchecked. -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="notifications_new_message"
|
||||||
|
android:title="@string/pref_title_new_message_notifications"/>
|
||||||
|
|
||||||
|
<!-- Allows the user to choose a ringtone in the 'notification' category. -->
|
||||||
|
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||||
|
<!-- NOTE: RingtonePreference's summary should be set to its value by the activity code. -->
|
||||||
|
<RingtonePreference
|
||||||
|
android:defaultValue="content://settings/system/notification_sound"
|
||||||
|
android:dependency="notifications_new_message"
|
||||||
|
android:key="notifications_new_message_ringtone"
|
||||||
|
android:ringtoneType="notification"
|
||||||
|
android:title="@string/pref_title_ringtone"/>
|
||||||
|
|
||||||
|
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:dependency="notifications_new_message"
|
||||||
|
android:key="notifications_new_message_vibrate"
|
||||||
|
android:title="@string/pref_title_vibrate"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue