Search in sources :

Example 1 with LockView

use of de.Maxr1998.xposed.maxlock.ui.lockscreen.LockView in project MaxLock by Maxr1998.

the class SettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    if (MLPreferences.getPreferences(this).getInt(FirstStartActivity.FIRST_START_LAST_VERSION_KEY, 0) != FirstStartActivity.FIRST_START_LATEST_VERSION) {
        startActivity(new Intent(this, FirstStartActivity.class));
    }
    devicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
    deviceAdmin = new ComponentName(this, UninstallProtectionReceiver.class);
    setContentView(R.layout.activity_settings);
    contentView = findViewById(R.id.content_view_settings);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    secondFragmentContainer = findViewById(R.id.second_fragment_container);
    Fragment settingsFragment = getSupportFragmentManager().findFragmentByTag(TAG_PREFERENCE_FRAGMENT);
    if (settingsFragment == null || !UNLOCKED) {
        // Main fragment doesn't exist, app just opened
        // → Show lockscreen
        UNLOCKED = false;
        if (!MLPreferences.getPreferences(this).getString(Common.LOCKING_TYPE, "").isEmpty()) {
            contentView.addView(lockscreen = new LockView(this, null), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            // → Hide Action bar
            toolbar.setTranslationY(-getResources().getDimensionPixelSize(R.dimen.toolbar_height));
        } else
            UNLOCKED = true;
        // → Create and display settings
        settingsFragment = getIntent().getAction() != null && getIntent().getAction().equals(BuildConfig.APPLICATION_ID + ".VIEW_APPS") ? new AppListFragment() : MaxLockPreferenceFragment.Screen.MAIN.getScreen();
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, settingsFragment, TAG_PREFERENCE_FRAGMENT).commit();
    }
    mConnection = new CustomTabsServiceConnection() {

        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) {
            customTabsClient.warmup(0);
            mSession = customTabsClient.newSession(new CustomTabsCallback());
            if (mSession == null) {
                return;
            }
            Bundle maxr1998Website = new Bundle();
            maxr1998Website.putParcelable(CustomTabsService.KEY_URL, Common.MAXR1998_URI);
            Bundle technoSparksProfile = new Bundle();
            technoSparksProfile.putParcelable(CustomTabsService.KEY_URL, Common.TECHNO_SPARKS_URI);
            mSession.mayLaunchUrl(Common.WEBSITE_URI, null, Arrays.asList(maxr1998Website, technoSparksProfile));
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
        }
    };
    String cctPackageName = CustomTabsClient.getPackageName(this, Arrays.asList("com.android.chrome", "com.chrome.beta", "com.chrome.dev", "org.mozilla.firefox", "org.mozilla.firefox_beta"));
    if (cctPackageName != null) {
        CustomTabsClient.bindCustomTabsService(this, cctPackageName, mConnection);
    } else
        mConnection = null;
    getSupportLoaderManager().initLoader(Common.STARTUP_LOADER, null, this);
}
Also used : CustomTabsClient(android.support.customtabs.CustomTabsClient) Bundle(android.os.Bundle) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) MaxLockPreferenceFragment(de.Maxr1998.xposed.maxlock.ui.settings.MaxLockPreferenceFragment) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) Fragment(android.support.v4.app.Fragment) CustomTabsCallback(android.support.customtabs.CustomTabsCallback) FirstStartActivity(de.Maxr1998.xposed.maxlock.ui.firstStart.FirstStartActivity) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) LockView(de.Maxr1998.xposed.maxlock.ui.lockscreen.LockView) ComponentName(android.content.ComponentName) CustomTabsServiceConnection(android.support.customtabs.CustomTabsServiceConnection)

Example 2 with LockView

use of de.Maxr1998.xposed.maxlock.ui.lockscreen.LockView in project MaxLock by Maxr1998.

the class ActionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences prefsApps = MLPreferences.getPrefsApps(this);
    mode = getIntent().getIntExtra(ActionsHelper.ACTION_EXTRA_KEY, -1);
    if ((mode == ActionsHelper.ACTION_MASTER_SWITCH_OFF || mode == ActionsHelper.ACTION_TOGGLE_MASTER_SWITCH) && prefsApps.getBoolean(Common.MASTER_SWITCH_ON, true)) {
        super.onCreate(savedInstanceState);
        setContentView(new LockView(this, null, Common.MASTER_SWITCH_ON, getClass().getName()), new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    } else {
        ActionsHelper.callAction(mode, this);
        fireIntentAndFinish();
        super.onCreate(savedInstanceState);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) RelativeLayout(android.widget.RelativeLayout) LockView(de.Maxr1998.xposed.maxlock.ui.lockscreen.LockView)

Aggregations

LockView (de.Maxr1998.xposed.maxlock.ui.lockscreen.LockView)2 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 CustomTabsCallback (android.support.customtabs.CustomTabsCallback)1 CustomTabsClient (android.support.customtabs.CustomTabsClient)1 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)1 CustomTabsServiceConnection (android.support.customtabs.CustomTabsServiceConnection)1 Fragment (android.support.v4.app.Fragment)1 RelativeLayout (android.widget.RelativeLayout)1 FirstStartActivity (de.Maxr1998.xposed.maxlock.ui.firstStart.FirstStartActivity)1 MaxLockPreferenceFragment (de.Maxr1998.xposed.maxlock.ui.settings.MaxLockPreferenceFragment)1 AppListFragment (de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment)1