Java Code Examples for androidx.appcompat.app.AppCompatDelegate#setCompatVectorFromResourcesEnabled()

The following examples show how to use androidx.appcompat.app.AppCompatDelegate#setCompatVectorFromResourcesEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyApplication.java    From weather with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  super.onCreate();
  ViewPump.init(ViewPump.builder()
      .addInterceptor(new CalligraphyInterceptor(
          new CalligraphyConfig.Builder()
              .setDefaultFontPath("fonts/Vazir.ttf")
              .setFontAttrId(R.attr.fontPath)
              .build()))
      .build());
  createBoxStore();
  if (SharedPreferencesUtil.getInstance(this).isDarkThemeEnabled())
    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
  else
    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
 
Example 2
Source File: SkinApp.java    From Android-skin-support with MIT License 6 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        Slog.DEBUG = BuildConfig.DEBUG;
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        SkinCompatManager.withoutActivity(this)
//                .addStrategy(new CustomSDCardLoader())          // 自定义加载策略,指定SDCard路径
//                .addStrategy(new ZipSDCardLoader())             // 自定义加载策略,获取zip包中的资源
                .addInflater(new SkinAppCompatViewInflater())   // 基础控件换肤
                .addInflater(new SkinMaterialViewInflater())    // material design
                .addInflater(new SkinConstraintViewInflater())  // ConstraintLayout
                .addInflater(new SkinCardViewInflater())        // CardView v7
//                .setSkinStatusBarColorEnable(true)              // 关闭状态栏换肤
//                .setSkinWindowBackgroundEnable(false)           // 关闭windowBackground换肤
//                .setSkinAllActivityEnable(false)                // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤
                .loadSkin();
    }
 
Example 3
Source File: BitmaskApp.java    From bitmask_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    refWatcher = LeakCanary.install(this);
    // Normal app init code...*/
    PRNGFixes.apply();
    SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
    providerObservable = ProviderObservable.getInstance();
    providerObservable.updateProvider(getSavedProviderFromSharedPreferences(preferences));
    EipSetupObserver.init(this, preferences);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    TetheringStateManager.getInstance().init(this);
}
 
Example 4
Source File: ApplicationContext.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  Log.i(TAG, "onCreate()");
  initializeSecurityProvider();
  initializeTypingStatusRepository();
  initializeTypingStatusSender();
  initializeRingRtc();
  initializeBlobProvider();
  ProcessLifecycleOwner.get().getLifecycle().addObserver(this);

  if (Build.VERSION.SDK_INT < 21) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  }

  initializePassphraseLock();
}
 
Example 5
Source File: IntervalTimerApp.java    From privacy-friendly-interval-timer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        // channels
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Default", NotificationManager.IMPORTANCE_LOW);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (notificationManager != null) {
            notificationManager.createNotificationChannel(channel);
        }
    }
}
 
Example 6
Source File: EntryThumbnail.java    From andOTP with MIT License 5 votes vote down vote up
public static Bitmap getThumbnailGraphic(Context context, String issuer, String label, int size, EntryThumbnails thumbnail) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    if (thumbnail == EntryThumbnails.Default && size > 0) {
        LetterBitmap letterBitmap = new LetterBitmap(context);
        String letterSrc = issuer.isEmpty() ? label : issuer;
        return letterBitmap.getLetterTile(letterSrc, letterSrc, size, size);
    } else if (thumbnail != EntryThumbnails.Default) {

        try {
            if (thumbnail.getAssetType() == AssetType.Vector) {
                Drawable drawable = AppCompatResources.getDrawable(context, thumbnail.getResource());
                Bitmap bitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(bitmap);
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                drawable.draw(canvas);
                return bitmap;
            } else {
                return BitmapFactory.decodeResource(context.getResources(), thumbnail.getResource());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher_round);
}
 
Example 7
Source File: FloatingNavigationView.java    From Floating-Navigation-View with Apache License 2.0 5 votes vote down vote up
public FloatingNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setImageResource(R.drawable.ic_menu_vector);

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    mNavigationView = (CircularRevealNavigationView) LayoutInflater.from(context).inflate(R.layout.navigation_view, null);
    mNavigationView.setBackground(new ColorDrawable(getBackgroundColor()));
    mNavigationView.setOnTouchListener(mNavigationTouchListener);
    mNavigationMenuView = (NavigationMenuView) mNavigationView.findViewById(R.id.design_navigation_view);

    mFabView = (ImageView) mNavigationView.findViewById(R.id.fab_view);
    mFabView.setOnClickListener(mFabClickListener);
    mFabView.setContentDescription(getContentDescription());
    mFabView.bringToFront();

    // Custom attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MenuView, defStyleAttr, R.style.Widget_Design_NavigationView);
    if (a.hasValue(R.styleable.MenuView_menu)) {
        mNavigationView.inflateMenu(a.getResourceId(R.styleable.MenuView_menu, 0));
    }
    if (a.hasValue(R.styleable.MenuView_headerLayout)) {
        mNavigationView.inflateHeaderView(a.getResourceId(R.styleable.MenuView_headerLayout, 0));
    }
    mDrawMenuBelowFab = a.getBoolean(R.styleable.MenuView_drawMenuBelowFab, false);
    a.recycle();
}
 
Example 8
Source File: SettingsActivity.java    From TwistyTimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    super.onCreate(savedInstanceState);

    mContext = getContext();

    averageText = getString(R.string.graph_legend_avg_prefix);
}
 
Example 9
Source File: Application.java    From power-adapters with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    RxJavaPlugins.setErrorHandler(e -> Log.e(TAG, "RxJava error", e));
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    LeakCanary.install(this);
}
 
Example 10
Source File: CatalogApplication.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  if (!overrideApplicationComponent(this)) {
    DaggerCatalogApplicationComponent.builder().application(this).build().inject(this);
  }
}
 
Example 11
Source File: DynamicApplication.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    DynamicTheme.getInstance().setDynamicThemeWork(onSetupDynamicWork());
    mConfiguration = new Configuration(getResources().getConfiguration());

    onInitialize();
    setDynamicTheme();
}
 
Example 12
Source File: ShrineApplication.java    From material-components-android-codelabs with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    instance = this;

    this.setAppContext(getApplicationContext());
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
 
Example 13
Source File: BlinkyApplication.java    From Android-nRF-Blinky with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    // Added to support vector drawables for devices below Android 21.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }
}
 
Example 14
Source File: TransportModePanel.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
/**
 * Init content.
 */
private void init(final Context context) {
    setOrientation(VERTICAL);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    LayoutInflater.from(context).inflate(R.layout.transport_mode_panel, this);
    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setVisibility(GONE);
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mTabLayout.addOnTabSelectedListener(this);
    mDataSetObserver = new DataSetChangeObserver();
    setAdapter(new SimpleTransportModePanelAdapter(getContext()));
}
 
Example 15
Source File: MainActivity.java    From AndroidApp with Mozilla Public License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        setContentView(R.layout.activity_main);
        //load last known location from SharedPreferences
        lastKnownLocation = new StorageUtil(this).getLastKnownLocation();

        if (lastKnownLocation == null) {
            registerReceiver(locationEnabledReceiver, new IntentFilter("LOCATION_ENABLED"));
        }

        //request permissions
        requestWriteExternalStoragePermission();

        getStatusBatColor();
        updateStatusBarColor();
        viewSetup();

        setupOsmConnection();

//        AppLog.log("OAUTH");
//        AppLog.log(osm.getUserAgent());
//        AppLog.log(osm.getApiUrl());
//        AppLog.log(osm.getOAuth().getConsumerKey());
//        AppLog.log(osm.getOAuth().getConsumerSecret());
//        AppLog.log(osm.getOAuth().getRequestParameters());
//        logUserInfo();
    }
 
Example 16
Source File: MainActivity.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle bundle) {
  super.onCreate(bundle);

  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  setContentView(R.layout.activity_main);

  RecyclerView modeRecyclerView = findViewById(R.id.mode_recycler_view);
  modeRecyclerView.setHasFixedSize(true);
  modeRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  modeRecyclerView.setAdapter(new ModeItemAdapter(DetectionMode.values()));
}
 
Example 17
Source File: EntryChoiceActivity.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle bundle) {
    super.onCreate(bundle);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_entry_choice);

    RecyclerView entryRecyclerView = findViewById(R.id.entry_recycler_view);
    entryRecyclerView.setHasFixedSize(true);
    entryRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    entryRecyclerView.setAdapter(new EntryItemAdapter(EntryMode.values()));
}
 
Example 18
Source File: MeshApplication.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    AppInjector.init(this);
}
 
Example 19
Source File: Application.java    From AppAuth-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
 
Example 20
Source File: App.java    From BreadcrumbsView with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}