Search in sources :

Example 16 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class NotificationUtils method createFtpNotification.

public static void createFtpNotification(Context context, Intent intent, int notification_id) {
    RootInfo root = intent.getExtras().getParcelable(EXTRA_ROOT);
    if (null == root) {
        return;
    }
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    long when = System.currentTimeMillis();
    CharSequence contentTitle = getString(context, R.string.ftp_notif_title);
    CharSequence contentText = String.format(getString(context, R.string.ftp_notif_text), ConnectionUtils.getFTPAddress(context));
    CharSequence tickerText = getString(context, R.string.ftp_notif_starting);
    CharSequence stopText = getString(context, R.string.ftp_notif_stop_server);
    Intent notificationIntent = new Intent(context, DocumentsActivity.class);
    notificationIntent.setData(root.getUri());
    notificationIntent.putExtras(intent.getExtras());
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    Intent stopIntent = new Intent(ACTION_STOP_FTPSERVER);
    stopIntent.putExtras(intent.getExtras());
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 0, stopIntent, PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(contentTitle).setContentText(contentText).setContentIntent(contentIntent).setSmallIcon(R.drawable.ic_stat_server).setTicker(tickerText).setWhen(when).setOngoing(true).setColor(SettingsActivity.getPrimaryColor()).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_SERVICE).setPriority(Notification.PRIORITY_MAX).addAction(R.drawable.ic_action_stop, stopText, stopPendingIntent).setShowWhen(false);
    Notification notification = builder.build();
    notificationManager.notify(notification_id, notification);
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 17 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class HomeFragment method showStorage.

private void showStorage() {
    final RootInfo primaryRoot = roots.getPrimaryRoot();
    if (null != primaryRoot) {
        storageStats.setVisibility(View.VISIBLE);
        storageStats.setInfo(primaryRoot);
        storageStats.setAction(R.drawable.ic_analyze, new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                ((DocumentsActivity) getActivity()).showInfo("Coming Soon!");
                Bundle params = new Bundle();
                AnalyticsManager.logEvent("storage_analyze", params);
            }
        });
        storageStats.setCardListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                openRoot(primaryRoot);
            }
        });
        storageTimer = new Timer();
        animateProgress(storageStats, storageTimer, primaryRoot);
    } else {
        storageStats.setVisibility(View.GONE);
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) Timer(java.util.Timer) Bundle(android.os.Bundle) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 18 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class HomeFragment method showOtherStorage.

private void showOtherStorage() {
    final RootInfo secondaryRoot = roots.getSecondaryRoot();
    if (null != secondaryRoot) {
        secondayStorageStats.setVisibility(View.VISIBLE);
        secondayStorageStats.setInfo(secondaryRoot);
        secondayStorageStats.setCardListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                openRoot(secondaryRoot);
            }
        });
        secondatyStorageTimer = new Timer();
        animateProgress(secondayStorageStats, secondatyStorageTimer, secondaryRoot);
    } else {
        secondayStorageStats.setVisibility(View.GONE);
    }
    final RootInfo usbRoot = roots.getUSBRoot();
    if (null != usbRoot) {
        usbStorageStats.setVisibility(View.VISIBLE);
        usbStorageStats.setInfo(usbRoot);
        usbStorageStats.setCardListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                openRoot(usbRoot);
            }
        });
        usbStorageTimer = new Timer();
        animateProgress(usbStorageStats, usbStorageTimer, usbRoot);
    } else {
        usbStorageStats.setVisibility(View.GONE);
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) Timer(java.util.Timer) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 19 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class DocumentsActivity method onCreate.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(Bundle icicle) {
    setTheme(R.style.Theme_Document);
    if (Utils.hasLollipop()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    } else if (Utils.hasKitKat()) {
        setTheme(R.style.Theme_Document_Translucent);
    }
    setUpStatusBar();
    /*		StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
				.penaltyLog()
				.build());
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll()
				.penaltyLog()
				.build());
*/
    super.onCreate(icicle);
    mRoots = DocumentsApplication.getRootsCache(this);
    setResult(Activity.RESULT_CANCELED);
    setContentView(R.layout.activity);
    final Context context = this;
    final Resources res = getResources();
    mShowAsDialog = res.getBoolean(R.bool.show_as_dialog);
    mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory);
    mRateContainer = (FrameLayout) findViewById(R.id.container_rate);
    initControls();
    if (icicle != null) {
        mState = icicle.getParcelable(EXTRA_STATE);
        mAuthenticated = icicle.getBoolean(EXTRA_AUTHENTICATED);
        mActionMode = icicle.getBoolean(EXTRA_ACTIONMODE);
    } else {
        buildDefaultState();
    }
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitleTextAppearance(context, R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
    if (Utils.hasKitKat() && !Utils.hasLollipop()) {
        ((LinearLayout.LayoutParams) mToolbar.getLayoutParams()).setMargins(0, getStatusBarHeight(this), 0, 0);
        mToolbar.setPadding(0, getStatusBarHeight(this), 0, 0);
    }
    mToolbarStack = (Spinner) findViewById(R.id.stack);
    mToolbarStack.setOnItemSelectedListener(mStackListener);
    setSupportActionBar(mToolbar);
    mRootsContainer = findViewById(R.id.drawer_roots);
    mInfoContainer = findViewById(R.id.container_info);
    if (!mShowAsDialog) {
        // Non-dialog means we have a drawer
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close);
        mDrawerLayout.setDrawerListener(mDrawerListener);
        // mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START);
        lockInfoContainter();
    }
    changeActionBarColor();
    initProtection();
    // Hide roots when we're managing a specific root
    if (mState.action == ACTION_MANAGE) {
        if (mShowAsDialog) {
            findViewById(R.id.container_roots).setVisibility(View.GONE);
        } else {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    }
    if (mState.action == ACTION_CREATE) {
        final String mimeType = getIntent().getType();
        final String title = getIntent().getStringExtra(IntentUtils.EXTRA_TITLE);
        SaveFragment.show(getFragmentManager(), mimeType, title);
    } else if (mState.action == ACTION_OPEN_TREE) {
        PickFragment.show(getFragmentManager());
    }
    if (mState.action == ACTION_BROWSE) {
        final Intent moreApps = new Intent(getIntent());
        moreApps.setComponent(null);
        moreApps.setPackage(null);
        RootsFragment.show(getFragmentManager(), moreApps);
    } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE || mState.action == ACTION_GET_CONTENT || mState.action == ACTION_OPEN_TREE) {
        RootsFragment.show(getFragmentManager(), new Intent());
    }
    if (!mState.restored) {
        if (mState.action == ACTION_MANAGE) {
            final Uri rootUri = getIntent().getData();
            new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor());
        } else {
            if (isDownloadAuthority(getIntent())) {
                onRootPicked(getDownloadRoot(), true);
            } else if (ConnectionUtils.isServerAuthority(getIntent())) {
                RootInfo root = getIntent().getExtras().getParcelable(EXTRA_ROOT);
                onRootPicked(root, true);
            } else if (Utils.isQSTile(getIntent())) {
                NetworkConnection networkConnection = NetworkConnection.getDefaultServer(this);
                RootInfo root = mRoots.getRootInfo(networkConnection);
                onRootPicked(root, true);
            } else {
                try {
                    new RestoreStackTask().execute();
                } catch (SQLiteFullException e) {
                    CrashReportingManager.logException(e);
                }
            }
        }
    } else {
        onCurrentDirectoryChanged(ANIM_NONE);
    }
    if (!PermissionUtil.hasStoragePermission(this)) {
        requestStoragePermissions();
    }
}
Also used : Context(android.content.Context) LayoutParams(android.view.ViewGroup.LayoutParams) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) SQLiteFullException(android.database.sqlite.SQLiteFullException) NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) Resources(android.content.res.Resources) Uri(android.net.Uri) TargetApi(android.annotation.TargetApi)

Example 20 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class DocumentsActivity method updateMenuItems.

public void updateMenuItems(Menu menu) {
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();
    if (isTelevision()) {
        menu.findItem(R.id.menu_create_dir).setVisible(showActionMenu());
        menu.findItem(R.id.menu_create_file).setVisible(showActionMenu());
    }
    final MenuItem search = menu.findItem(R.id.menu_search);
    final MenuItem sort = menu.findItem(R.id.menu_sort);
    final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
    final MenuItem grid = menu.findItem(R.id.menu_grid);
    final MenuItem list = menu.findItem(R.id.menu_list);
    final MenuItem settings = menu.findItem(R.id.menu_settings);
    // Open drawer means we hide most actions
    if (isRootsDrawerOpen()) {
        search.setVisible(false);
        sort.setVisible(false);
        grid.setVisible(false);
        list.setVisible(false);
        mIgnoreNextCollapse = true;
        search.collapseActionView();
        return;
    }
    sort.setVisible(cwd != null);
    grid.setVisible(!RootInfo.isOtherRoot(getCurrentRoot()) && mState.derivedMode != MODE_GRID);
    list.setVisible(mState.derivedMode != MODE_LIST);
    if (mState.currentSearch != null) {
        // Search uses backend ranking; no sorting
        // sort.setVisible(false);
        search.expandActionView();
        mSearchView.setIconified(false);
        mSearchView.clearFocus();
        mSearchView.setQuery(mState.currentSearch, false);
    } else {
        mIgnoreNextClose = true;
        mSearchView.setIconified(true);
        mSearchView.clearFocus();
        mIgnoreNextCollapse = true;
        search.collapseActionView();
    }
    // Only sort by size when visible
    sortSize.setVisible(mState.showSize);
    final boolean searchVisible;
    if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
        searchVisible = false;
        // No display options in recent directories
        if (cwd == null) {
            grid.setVisible(false);
            list.setVisible(false);
        }
        if (mState.action == State.ACTION_CREATE) {
            if (null != SaveFragment.get(fm))
                SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());
        }
    } else {
        searchVisible = root != null && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0);
        // TODO: Is this useful?
        if (null != SaveFragment.get(fm))
            SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());
        if (null != MoveFragment.get(fm))
            MoveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isMoveSupported());
    }
    // TODO: close any search in-progress when hiding
    search.setVisible(searchVisible);
    settings.setVisible(mState.action != ACTION_MANAGE);
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) MenuItem(android.view.MenuItem) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Aggregations

RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)26 Bundle (android.os.Bundle)5 View (android.view.View)5 TextView (android.widget.TextView)5 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)5 ArrayList (java.util.ArrayList)5 FragmentManager (android.app.FragmentManager)4 Uri (android.net.Uri)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Intent (android.content.Intent)3 BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)3 Timer (java.util.Timer)3 TargetApi (android.annotation.TargetApi)2 Context (android.content.Context)2 Loader (android.content.Loader)2 Cursor (android.database.Cursor)2 MenuItem (android.view.MenuItem)2 State (dev.dworks.apps.anexplorer.BaseActivity.State)2 RootsFragment (dev.dworks.apps.anexplorer.fragment.RootsFragment)2 SaveFragment (dev.dworks.apps.anexplorer.fragment.SaveFragment)2