content: package com.ammar.sharing.custom.ui;
  
  import static com.ammar.sharing.activities.MainActivity.MainActivity.sDarkMode;
  
  import android.os.Bundle;
  import android.view.MenuItem;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.appcompat.app.AppCompatDelegate;
  
  import com.ammar.sharing.R;
  
  public class DefaultActivity extends AppCompatActivity {
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (sDarkMode) {
              setTheme(R.style.AppThemeDark);
              getWindow().setBackgroundDrawableResource(R.drawable.gradient_background_dark);
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
          } else {
              getWindow().setBackgroundDrawableResource(R.drawable.gradient_background_light);
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
          }
      }
  
      @Override
      public boolean onOptionsItemSelected(@NonNull MenuItem item) {
          int id = item.getItemId();
          if (id == android.R.id.home) {
              setResult(RESULT_CANCELED);
              finish();
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }