mirror of
				https://github.com/yggdrasil-network/yggdrasil-android.git
				synced 2025-11-04 03:05:08 +03:00 
			
		
		
		
	Optimization and localizations. (#27)
* Optimized UI refresh to save battery. Extracted all strings to xml to enable localizations. * And added Russian localization.
This commit is contained in:
		
							parent
							
								
									8615d43761
								
							
						
					
					
						commit
						41569a9ee2
					
				
					 12 changed files with 274 additions and 157 deletions
				
			
		| 
						 | 
				
			
			@ -1,25 +1,27 @@
 | 
			
		|||
package eu.neilalexander.yggdrasil
 | 
			
		||||
 | 
			
		||||
import android.app.Application
 | 
			
		||||
import android.content.IntentFilter
 | 
			
		||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
 | 
			
		||||
 | 
			
		||||
class GlobalApplication: Application() {
 | 
			
		||||
    private var state = PacketTunnelState
 | 
			
		||||
    private lateinit var config: ConfigurationProxy
 | 
			
		||||
    var updaterConnections: Int = 0
 | 
			
		||||
 | 
			
		||||
    override fun onCreate() {
 | 
			
		||||
        super.onCreate()
 | 
			
		||||
        config = ConfigurationProxy(applicationContext)
 | 
			
		||||
 | 
			
		||||
        LocalBroadcastManager.getInstance(this).registerReceiver(
 | 
			
		||||
            state, IntentFilter(PacketTunnelProvider.RECEIVER_INTENT)
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun onTerminate() {
 | 
			
		||||
        super.onTerminate()
 | 
			
		||||
    fun subscribe() {
 | 
			
		||||
        updaterConnections++
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        LocalBroadcastManager.getInstance(this).unregisterReceiver(state)
 | 
			
		||||
    fun unsubscribe() {
 | 
			
		||||
        if (updaterConnections > 0) {
 | 
			
		||||
            updaterConnections--
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun needUiUpdates(): Boolean {
 | 
			
		||||
        return updaterConnections > 0
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue