Search in sources :

Example 11 with ActionBar

use of androidx.appcompat.app.ActionBar in project android by owncloud.

the class ManageSpaceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manage_space);
    // Allow or disallow touches with other visible windows
    LinearLayout manageSpaceLayout = findViewById(R.id.manage_space_layout);
    manageSpaceLayout.setFilterTouchesWhenObscured(PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(this));
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.manage_space_title);
    TextView descriptionTextView = findViewById(R.id.general_description);
    descriptionTextView.setText(getString(R.string.manage_space_description, getString(R.string.app_name)));
    Button clearDataButton = findViewById(R.id.clearDataButton);
    clearDataButton.setOnClickListener(v -> {
        ClearDataAsyncTask clearDataTask = new ClearDataAsyncTask();
        clearDataTask.execute();
    });
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) ActionBar(androidx.appcompat.app.ActionBar)

Example 12 with ActionBar

use of androidx.appcompat.app.ActionBar in project kdeconnect-android by KDE.

the class ShareActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ThemeUtil.setUserPreferredTheme(this);
    binding = ActivityShareBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    setSupportActionBar(binding.toolbarLayout.toolbar);
    Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    ActionBar actionBar = getSupportActionBar();
    binding.devicesListLayout.refreshListLayout.setOnRefreshListener(this::updateComputerListAction);
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
    }
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 13 with ActionBar

use of androidx.appcompat.app.ActionBar in project android by owncloud.

the class PreviewImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.preview_image_activity);
    // ActionBar
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
    showActionBar(false);
    // / FullScreen and Immersive Mode
    mFullScreenAnchorView = getWindow().getDecorView();
    // to keep our UI controls visibility in line with system bars
    // visibility
    mFullScreenAnchorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @SuppressLint("InlinedApi")
        @Override
        public void onSystemUiVisibilityChange(int flags) {
            boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
            if (visible) {
                showActionBar(true);
                setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            } else {
                showActionBar(false);
                setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
            }
        }
    });
    getWindow().setStatusBarColor(getResources().getColor(R.color.owncloud_blue_dark_transparent));
    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
}
Also used : SuppressLint(android.annotation.SuppressLint) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 14 with ActionBar

use of androidx.appcompat.app.ActionBar in project Tusky by Vavassor.

the class ViewTagActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_tag);
    String hashtag = getIntent().getStringExtra(HASHTAG);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setTitle(String.format(getString(R.string.title_tag), hashtag));
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
    }
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    Fragment fragment = TimelineFragment.newHashtagInstance(Collections.singletonList(hashtag));
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) TimelineFragment(com.keylesspalace.tusky.components.timeline.TimelineFragment) Fragment(androidx.fragment.app.Fragment) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with ActionBar

use of androidx.appcompat.app.ActionBar in project kdeconnect-android by KDE.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Workaround: If the activity starts in landscape orientation and we call this before super.onCreate, the PluginItem entries appears with white on white background
    ThemeUtil.setUserPreferredTheme(this);
    final ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    mNavigationView = binding.navigationDrawer;
    mDrawerLayout = binding.drawerLayout;
    View mDrawerHeader = mNavigationView.getHeaderView(0);
    mNavViewDeviceName = mDrawerHeader.findViewById(R.id.device_name);
    ImageView mNavViewDeviceType = mDrawerHeader.findViewById(R.id.device_type);
    setSupportActionBar(binding.toolbarLayout.toolbar);
    ActionBar actionBar = getSupportActionBar();
    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.string.open, /* "open drawer" description */
    R.string.close);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerToggle.syncState();
    preferences = getSharedPreferences("stored_menu_selection", Context.MODE_PRIVATE);
    // Note: The preference changed listener should be registered before getting the name, because getting
    // it can trigger a background fetch from the internet that will eventually update the preference
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
    String deviceName = DeviceHelper.getDeviceName(this);
    mNavViewDeviceType.setImageDrawable(DeviceHelper.getDeviceType(this).getIcon(this));
    mNavViewDeviceName.setText(deviceName);
    mNavigationView.setNavigationItemSelectedListener(menuItem -> {
        mCurrentMenuEntry = menuItem.getItemId();
        switch(mCurrentMenuEntry) {
            case MENU_ENTRY_ADD_DEVICE:
                mCurrentDevice = null;
                preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply();
                setContentFragment(new PairingFragment());
                break;
            case MENU_ENTRY_SETTINGS:
                mCurrentDevice = null;
                preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply();
                setContentFragment(new SettingsFragment());
                break;
            case MENU_ENTRY_ABOUT:
                mCurrentDevice = null;
                preferences.edit().putString(STATE_SELECTED_DEVICE, null).apply();
                setContentFragment(AboutFragment.newInstance(Objects.requireNonNull(ApplicationAboutDataKt.getApplicationAboutData(this))));
                break;
            default:
                String deviceId = mMapMenuToDeviceId.get(menuItem);
                onDeviceSelected(deviceId);
                break;
        }
        mDrawerLayout.closeDrawer(mNavigationView);
        return true;
    });
    // Decide which menu entry should be selected at start
    String savedDevice;
    int savedMenuEntry;
    if (getIntent().hasExtra("forceOverview")) {
        Log.i("MainActivity", "Requested to start main overview");
        savedDevice = null;
        savedMenuEntry = MENU_ENTRY_ADD_DEVICE;
    } else if (getIntent().hasExtra(EXTRA_DEVICE_ID)) {
        Log.i("MainActivity", "Loading selected device from parameter");
        savedDevice = getIntent().getStringExtra(EXTRA_DEVICE_ID);
        savedMenuEntry = MENU_ENTRY_DEVICE_UNKNOWN;
        // If pairStatus is not empty, then the user has accepted/reject the pairing from the notification
        String pairStatus = getIntent().getStringExtra(PAIR_REQUEST_STATUS);
        if (pairStatus != null) {
            Log.i("MainActivity", "pair status is " + pairStatus);
            savedDevice = onPairResultFromNotification(savedDevice, pairStatus);
            if (savedDevice == null) {
                savedMenuEntry = MENU_ENTRY_ADD_DEVICE;
            }
        }
    } else if (savedInstanceState != null) {
        Log.i("MainActivity", "Loading selected device from saved activity state");
        savedDevice = savedInstanceState.getString(STATE_SELECTED_DEVICE);
        savedMenuEntry = savedInstanceState.getInt(STATE_SELECTED_MENU_ENTRY, MENU_ENTRY_ADD_DEVICE);
    } else {
        Log.i("MainActivity", "Loading selected device from persistent storage");
        savedDevice = preferences.getString(STATE_SELECTED_DEVICE, null);
        savedMenuEntry = (savedDevice != null) ? MENU_ENTRY_DEVICE_UNKNOWN : MENU_ENTRY_ADD_DEVICE;
    }
    mCurrentMenuEntry = savedMenuEntry;
    mCurrentDevice = savedDevice;
    mNavigationView.setCheckedItem(savedMenuEntry);
    // FragmentManager will restore whatever fragment was there
    if (savedInstanceState != null) {
        Fragment frag = getSupportFragmentManager().findFragmentById(R.id.container);
        if (!(frag instanceof DeviceFragment) || ((DeviceFragment) frag).getDeviceId().equals(savedDevice)) {
            return;
        }
    }
    // Activate the chosen fragment and select the entry in the menu
    if (savedMenuEntry >= MENU_ENTRY_DEVICE_FIRST_ID && savedDevice != null) {
        onDeviceSelected(savedDevice);
    } else {
        if (mCurrentMenuEntry == MENU_ENTRY_SETTINGS) {
            setContentFragment(new SettingsFragment());
        } else if (mCurrentMenuEntry == MENU_ENTRY_ABOUT) {
            setContentFragment(AboutFragment.newInstance(Objects.requireNonNull(ApplicationAboutDataKt.getApplicationAboutData(this))));
        } else {
            setContentFragment(new PairingFragment());
        }
    }
}
Also used : ShareSettingsFragment(org.kde.kdeconnect.Plugins.SharePlugin.ShareSettingsFragment) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) ActivityMainBinding(org.kde.kdeconnect_tp.databinding.ActivityMainBinding) NavigationView(com.google.android.material.navigation.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Fragment(androidx.fragment.app.Fragment) ShareSettingsFragment(org.kde.kdeconnect.Plugins.SharePlugin.ShareSettingsFragment) AboutFragment(org.kde.kdeconnect.UserInterface.About.AboutFragment) ActionBar(androidx.appcompat.app.ActionBar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)139 View (android.view.View)30 Toolbar (androidx.appcompat.widget.Toolbar)29 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)26 TextView (android.widget.TextView)18 Intent (android.content.Intent)11 Bundle (android.os.Bundle)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 ImageView (android.widget.ImageView)7 Uri (android.net.Uri)6 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)6 SharedPreferences (android.content.SharedPreferences)5 ListView (android.widget.ListView)5 Spinner (android.widget.Spinner)5 Typeface (com.mta.tehreer.graphics.Typeface)5 File (java.io.File)5 MenuItem (android.view.MenuItem)4 Button (android.widget.Button)4