Skip to content

Commit

Permalink
#169: Introduced empty abstract BaseActivity as root of inheritance c…
Browse files Browse the repository at this point in the history
…hain for all activities
  • Loading branch information
k3b committed Mar 22, 2020
1 parent cf141b5 commit 3d1ddb4
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 24 deletions.
42 changes: 42 additions & 0 deletions app/src/main/java/de/k3b/android/androFotoFinder/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

package de.k3b.android.androFotoFinder;

import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.ActivityWithCallContext;
import de.k3b.android.widget.BaseQueryActivity;
import de.k3b.android.widget.FilePermissionActivity;
import de.k3b.android.widget.LocalizedActivity;
import de.k3b.android.widget.PermissionBaseActivity;

/**
* Nearly all activities are inherited from {@link BaseActivity}.
* * {@link FilePermissionActivity} manage permission write to external-storage and to sdcard
* * {@link PermissionBaseActivity} can Ask for permission
* * {@link ActivityWithAutoCloseDialogs} Automatically closes pop-dialogs
* * {@link LocalizedActivity} Change the locale (language) and translation of its content at runtime
* * {@link ActivityWithCallContext} memorizes the activity call stack (parent Activities) for debugging purposes.
* <p>
* * {@link BaseQueryActivity} filtered collection of photos used by
* ** {@link de.k3b.android.androFotoFinder.FotoGalleryActivity}
* ** {@link de.k3b.android.androFotoFinder.locationmap.MapGeoPickerActivity}
*/
public abstract class BaseActivity extends FilePermissionActivity {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2019 by k3b.
* Copyright (c) 2015-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -60,7 +60,6 @@
import de.k3b.android.osmdroid.OsmdroidUtil;
import de.k3b.android.util.IntentUtil;
import de.k3b.android.widget.AboutDialogPreference;
import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.BaseQueryActivity;
import de.k3b.android.widget.HistoryEditText;
import de.k3b.database.QueryParameter;
Expand All @@ -79,7 +78,7 @@
*
* Defines a gui for global foto filter: only fotos from certain filepath, date and/or lat/lon will be visible.
*/
public class GalleryFilterActivity extends ActivityWithAutoCloseDialogs
public class GalleryFilterActivity extends BaseActivity
implements Common, DirectoryPickerFragment.OnDirectoryInteractionListener,
LocationMapFragment.OnDirectoryInteractionListener,
TagsPickerFragment.ITagsPicker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019 by k3b.
* Copyright (c) 2017-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -58,7 +58,6 @@
import de.k3b.android.util.ClipboardUtil;
import de.k3b.android.util.IntentUtil;
import de.k3b.android.widget.AboutDialogPreference;
import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.HistoryEditText;
import de.k3b.io.DateUtil;
import de.k3b.io.ListUtils;
Expand All @@ -78,7 +77,7 @@
* * filename schemata for copied/moved files
* * default properties that every photot should receive.
*/
public class PhotoAutoprocessingEditActivity extends ActivityWithAutoCloseDialogs implements Common {
public class PhotoAutoprocessingEditActivity extends BaseActivity implements Common {
private static final String mDebugPrefix = "AutoProcEdit-";
private static final String SETTINGS_KEY = "AutoProcEditCurrent-";
private static final int EXIF_EDIT_RESULT_ID = 86441;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019 by k3b.
* Copyright (c) 2017-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -61,7 +61,6 @@
import de.k3b.android.util.PhotoPropertiesMediaFilesScanner;
import de.k3b.android.util.ResourceUtils;
import de.k3b.android.widget.AboutDialogPreference;
import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.HistoryEditText;
import de.k3b.android.widget.UpdateTask;
import de.k3b.geo.api.GeoPointDto;
Expand All @@ -86,7 +85,7 @@
* Modes: if IPhotoProperties is not null edit exif data witout modifying any jpg file.
* Modes: else if data-url/SelectedFiles is not null: modify the referenced jpg files.
*/
public class PhotoPropertiesEditActivity extends ActivityWithAutoCloseDialogs implements Common {
public class PhotoPropertiesEditActivity extends BaseActivity implements Common {
private static final boolean SYNC_UPDATE_EXIF = false; // for sync debugging. false: asynch task
private static final String mDebugPrefix = "ExifEdit-";
private static final String DLG_NAVIGATOR_TAG = mDebugPrefix;
Expand Down Expand Up @@ -380,7 +379,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
case R.id.cmd_ok:
onOk();
onSaveChanges();
return true;
case R.id.cmd_clear:
clearFilter();
Expand Down Expand Up @@ -796,7 +795,7 @@ private void clearFilter() {
}

/** save exif changes back to image and database */
private void onOk() {
private void onSaveChanges() {
Activity ctx = this;
saveGuiToExif("onOk (finish)");
mHistory.saveHistory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019 by k3b.
* Copyright (c) 2018-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -52,6 +52,7 @@
import java.util.TimeZone;

import de.k3b.android.androFotoFinder.AffUtils;
import de.k3b.android.androFotoFinder.BaseActivity;
import de.k3b.android.androFotoFinder.Common;
import de.k3b.android.androFotoFinder.FotoGalleryActivity;
import de.k3b.android.androFotoFinder.GalleryFilterActivity;
Expand All @@ -68,7 +69,6 @@
import de.k3b.android.util.IntentUtil;
import de.k3b.android.util.OsUtils;
import de.k3b.android.widget.AboutDialogPreference;
import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.HistoryEditText;
import de.k3b.database.QueryParameter;
import de.k3b.io.DateUtil;
Expand All @@ -95,7 +95,7 @@
* * uri = intent.getData() load file via file-uri
* * else intent.Extra[EXTRA_STATE_ZIP_CONFIG]
*/
public class BackupActivity extends ActivityWithAutoCloseDialogs implements Common {
public class BackupActivity extends BaseActivity implements Common {
private static final int REQUEST_ID_PICK_ZIP_OUT_DIR = 1234;

public static final int REQUEST_BACKUP_ID = 99289;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.List;

import de.k3b.android.androFotoFinder.AffUtils;
import de.k3b.android.androFotoFinder.BaseActivity;
import de.k3b.android.androFotoFinder.Common;
import de.k3b.android.androFotoFinder.FotoGalleryActivity;
import de.k3b.android.androFotoFinder.Global;
Expand All @@ -71,7 +72,6 @@
import de.k3b.android.util.PhotoPropertiesMediaFilesScanner;
import de.k3b.android.util.PhotoPropertiesMediaFilesScannerAsyncTask;
import de.k3b.android.widget.AboutDialogPreference;
import de.k3b.android.widget.ActivityWithAutoCloseDialogs;
import de.k3b.android.widget.ActivityWithCallContext;
import de.k3b.android.widget.Dialogs;
import de.k3b.database.QueryParameter;
Expand All @@ -93,7 +93,7 @@
* Swipe left/right to show previous/next image.
*/

public class ImageDetailActivityViewPager extends ActivityWithAutoCloseDialogs implements Common, TagsPickerFragment.ITagsPicker,
public class ImageDetailActivityViewPager extends BaseActivity implements Common, TagsPickerFragment.ITagsPicker,
PhotoChangeNotifyer.PhotoChangedListener {
private static final String INSTANCE_STATE_MODIFY_COUNT = "mModifyCount";
private static final String INSTANCE_STATE_LAST_SCROLL_POSITION = "lastScrollPosition";
Expand Down Expand Up @@ -1283,7 +1283,7 @@ public SelectedFiles getSrcFotos() {
}

/**
* To be overwritten to check if a path can be picked.
* To be overwritten to check if a path can be picked for writing.
*
* @param path to be checked if it cannot be handled
* @return null if no error else error message with the reason why it cannot be selected
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019 by k3b.
* Copyright (c) 2017-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -36,7 +36,7 @@
* Created by k3b on 21.06.2017.
*/

public class ActivityWithAutoCloseDialogs extends LocalizedActivity {
public abstract class ActivityWithAutoCloseDialogs extends LocalizedActivity {
protected DialogFragment mCurrentDialogFragment;
private Closeable mCloseable;
private DialogInterface mCurrentDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* <p>
* Created by k3b on 25.08.2018.
*/
public class ActivityWithCallContext extends Activity {
public abstract class ActivityWithCallContext extends Activity {
/**
* the CallContext is an intent-extra with this name
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2019 by k3b.
* Copyright (c) 2015-2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
Expand Down Expand Up @@ -41,6 +41,7 @@
import java.util.List;

import de.k3b.LibGlobal;
import de.k3b.android.androFotoFinder.BaseActivity;
import de.k3b.android.androFotoFinder.Common;
import de.k3b.android.androFotoFinder.GalleryFilterActivity;
import de.k3b.android.androFotoFinder.GalleryFilterPathState;
Expand Down Expand Up @@ -70,11 +71,12 @@
import de.k3b.tagDB.Tag;

/**
* All that is is needed for to have a base-filter plus a sub-filter
* An activity that can have a filtered collection of photos based on
* a base-filter plus a sub-filter
*
* Created by k3b on 10.07.2018.
*/
public abstract class BaseQueryActivity extends ActivityWithAutoCloseDialogs implements Common, DirectoryPickerFragment.OnDirectoryInteractionListener,
public abstract class BaseQueryActivity extends BaseActivity implements Common, DirectoryPickerFragment.OnDirectoryInteractionListener,
LocationMapFragment.OnDirectoryInteractionListener,
TagsPickerFragment.ITagsPicker {
protected static final String mDebugPrefix = "GalleryA-";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2020 by k3b.
*
* This file is part of AndroFotoFinder / #APhotoManager.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>
*/

package de.k3b.android.widget;

import android.Manifest;

/**
* Manage permission
* * write to external-storage and
* * write to sdcard/usbstick,....
*/
public abstract class FilePermissionActivity extends PermissionBaseActivity {
private void t() {
super.requestPermisson(Manifest.permission.WRITE_EXTERNAL_STORAGE,
"To %s the app needs write permission.",
(_this, result) -> onSaveChangesWithGrant(_this, result));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import de.k3b.android.util.UserTheme;

/**
* An activity that can change the locale (language) of its content.
* An activity that can change the locale (language) and translation of its content at runtime.
*
* Inspired by http://stackoverflow.com/questions/13181847/change-the-locale-at-runtime
*
Expand Down
Loading

0 comments on commit 3d1ddb4

Please sign in to comment.