Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 528877a4 authored by d34d's avatar d34d
Browse files

Add support for showing and moving files with CMFM [1/2]

Change-Id: I6851acf05a279a1b83bd041a4d90c8238892765d
parent c286a14c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@
      android:label="@string/picker"
      android:uiOptions="none"
      android:configChanges="orientation|keyboardHidden|screenSize"
      android:theme="@style/FileManager.Theme.PickerActivity"
      android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.GET_CONTENT" />
@@ -240,6 +241,11 @@
        <action android:name="android.intent.action.VIEW" />
      </intent-filter>
    </activity>

    <activity android:name=".activities.MoveDownloadedFileActivity"
      android:theme="@style/FileManager.Theme.Transparent"
      android:exported="true"/>

    <service android:name=".providers.secure.SecureCacheCleanupService">
      <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
@@ -248,6 +254,8 @@
      </intent-filter>
    </service>

    <service android:name=".service.MoveFileService" android:exported="false" />

  </application>

</manifest>
+2 −0
Original line number Diff line number Diff line
@@ -181,4 +181,6 @@

    <color name="open_file_progress_dialog_file_color">#de000000</color>
    <color name="open_file_progress_dialog_message_color">#8b000000</color>

    <color name="picker_activity_window_bg_color">#99000000</color>
</resources>
+14 −0
Original line number Diff line number Diff line
@@ -931,4 +931,18 @@
    <string name="docs">Docs</string>
    <string name="apps">Apps</string>
    <string name="archives">Archives</string>

    <!-- Moving file notifications -->
    <string name="moving_file_notification_title">Moving file</string>
    <string name="move_complete_notification_title">Move complete</string>
    <string name="move_complete_notification_description">Open location</string>
    <string name="move_complete_notification_share_link">Share link</string>
    <!-- Moving file error notifications -->
    <string name="moving_file_failed_notification_title">Unable to move</string>
    <string name="moving_file_failed_not_enough_space">Not enough space in source.  Free more space before retrying.</string>
    <string name="moving_file_failed_no_provider_connection">Tap to check account connection</string>
    <string name="moving_file_failed_no_data_connection">Check data connection and tap to retry</string>
    <string name="moving_file_failed_generic">Tap to retry</string>
    <string name="moving_file_failed_retry_action">Retry</string>
    <string name="moving_file_failed_upgrade_action">Upgrade</string>
</resources>
+18 −0
Original line number Diff line number Diff line
@@ -128,6 +128,24 @@
        <item name="android:homeAsUpIndicator">@drawable/material_ripple_up_arrow</item>
    </style>

    <style name="FileManager.Theme.Transparent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>

    <style name="FileManager.Theme.PickerActivity" parent="android:Theme.Material.Light">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:backgroundDimAmount">0.6</item>
    </style>

    <!-- Action bar -->
    <style name="FileManager.Widget.ActionBar.White" parent="@android:style/Widget.Material.Light.ActionBar">
        <item name="android:textColorPrimary">@android:color/white</item>
+71 −0
Original line number Diff line number Diff line
/*
* Copyright (C) 2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cyanogenmod.filemanager.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.cyanogenmod.filemanager.service.MoveFileService;

public class MoveDownloadedFileActivity extends Activity {
    private static final String TAG = MoveDownloadedFileActivity.class.getSimpleName();
    private static final boolean DEBUG = false;

    private static final String EXTRA_FILE_PATH = "extra_file_path";

    private static final int REQUEST_MOVE = 1000;

    private String mFilePath;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (savedInstanceState == null) {
            Intent intent = getIntent();
            if (intent == null || !intent.hasExtra(EXTRA_FILE_PATH)) {
                Log.w(TAG, "Null intent or no file specified");
                finish();
            } else {
                mFilePath = intent.getStringExtra(EXTRA_FILE_PATH);
                Intent moveIntent = new Intent(this, PickerActivity.class);
                moveIntent.setAction(PickerActivity.INTENT_FOLDER_SELECT);
                moveIntent.putExtra(PickerActivity.EXTRA_ACTION,
                        PickerActivity.ACTION_MODE.MOVE.ordinal());
                startActivityForResult(moveIntent, REQUEST_MOVE);
            }
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_MOVE) {
            if (resultCode == RESULT_OK && data.hasExtra(PickerActivity.EXTRA_FOLDER_PATH)) {
                String destinationPath = data.getStringExtra(PickerActivity.EXTRA_FOLDER_PATH);
                if (DEBUG) Log.d(TAG, String.format("Moving %s to %s", mFilePath, destinationPath));
                Intent intent = new Intent(this, MoveFileService.class);
                intent.putExtra(MoveFileService.EXTRA_SOURCE_FILE_PATH, mFilePath);
                intent.putExtra(MoveFileService.EXTRA_DESTINATION_FILE_PATH, destinationPath);
                startService(intent);
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
        finish();
    }
}
 No newline at end of file
Loading