@ -38,9 +38,11 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable ;
import android.graphics.drawable.Drawable ;
import android.media.Ringtone ;
import android.media.Ringtone ;
import android.media.RingtoneManager ;
import android.media.RingtoneManager ;
import android.net.ConnectivityManager ;
import android.net.Uri ;
import android.net.Uri ;
import android.os.Build ;
import android.os.Build ;
import android.os.Bundle ;
import android.os.Bundle ;
import android.provider.Settings ;
import android.text.TextUtils ;
import android.text.TextUtils ;
import android.view.LayoutInflater ;
import android.view.LayoutInflater ;
import android.view.MenuItem ;
import android.view.MenuItem ;
@ -66,6 +68,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager ;
import androidx.recyclerview.widget.LinearLayoutManager ;
import androidx.recyclerview.widget.RecyclerView ;
import androidx.recyclerview.widget.RecyclerView ;
import com.google.android.material.snackbar.Snackbar ;
import com.google.android.material.textfield.TextInputLayout ;
import com.google.android.material.textfield.TextInputLayout ;
import org.json.JSONArray ;
import org.json.JSONArray ;
@ -103,6 +106,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
private ActionBarDrawerToggle drawerToggle ;
private ActionBarDrawerToggle drawerToggle ;
private ConstraintLayout drawerContainer ;
private ConstraintLayout drawerContainer ;
private RecyclerView rvMenu ;
private RecyclerView rvMenu ;
private Snackbar sbDataSaver ;
private boolean hasAccount ;
private boolean hasAccount ;
private String password ;
private String password ;
@ -252,6 +256,20 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
adapter . set ( menus ) ;
adapter . set ( menus ) ;
sbDataSaver = Snackbar . make ( view , R . string . title_setup_data , Snackbar . LENGTH_INDEFINITE ) ;
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . N ) {
final Intent settings = new Intent (
Settings . ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS ,
Uri . parse ( "package:" + BuildConfig . APPLICATION_ID ) ) ;
if ( settings . resolveActivity ( getPackageManager ( ) ) ! = null )
sbDataSaver . setAction ( R . string . title_fix , new View . OnClickListener ( ) {
@Override
public void onClick ( View view ) {
startActivity ( settings ) ;
}
} ) ;
}
getSupportFragmentManager ( ) . addOnBackStackChangedListener ( this ) ;
getSupportFragmentManager ( ) . addOnBackStackChangedListener ( this ) ;
if ( getSupportFragmentManager ( ) . getFragments ( ) . size ( ) = = 0 ) {
if ( getSupportFragmentManager ( ) . getFragments ( ) . size ( ) = = 0 ) {
@ -297,6 +315,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override
@Override
protected void onResume ( ) {
protected void onResume ( ) {
super . onResume ( ) ;
super . onResume ( ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( this ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( this ) ;
IntentFilter iff = new IntentFilter ( ) ;
IntentFilter iff = new IntentFilter ( ) ;
iff . addAction ( ACTION_QUICK_SETUP ) ;
iff . addAction ( ACTION_QUICK_SETUP ) ;
@ -305,6 +324,16 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
iff . addAction ( ACTION_EDIT_ACCOUNT ) ;
iff . addAction ( ACTION_EDIT_ACCOUNT ) ;
iff . addAction ( ACTION_EDIT_IDENTITY ) ;
iff . addAction ( ACTION_EDIT_IDENTITY ) ;
lbm . registerReceiver ( receiver , iff ) ;
lbm . registerReceiver ( receiver , iff ) ;
// https://developer.android.com/training/basics/network-ops/data-saver.html
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . N ) {
ConnectivityManager cm = ( ConnectivityManager ) getSystemService ( Context . CONNECTIVITY_SERVICE ) ;
if ( cm ! = null ) {
int status = cm . getRestrictBackgroundStatus ( ) ;
if ( status = = ConnectivityManager . RESTRICT_BACKGROUND_STATUS_ENABLED )
sbDataSaver . show ( ) ;
}
}
}
}
@Override
@Override
@ -312,6 +341,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
super . onPause ( ) ;
super . onPause ( ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( this ) ;
LocalBroadcastManager lbm = LocalBroadcastManager . getInstance ( this ) ;
lbm . unregisterReceiver ( receiver ) ;
lbm . unregisterReceiver ( receiver ) ;
if ( sbDataSaver . isShown ( ) )
sbDataSaver . dismiss ( ) ;
}
}
@Override
@Override