Skip to content

Commit

Permalink
Merge branch 'master' into FDroid
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Sep 14, 2019
2 parents dad144e + 986ae88 commit a5efcbd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package de.k3b.android.androFotoFinder.directory;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class DirectoryLoaderTask extends AsyncTask<QueryParameter, Integer, IDir
// every 500 items the progress indicator is advanced
private static final int PROGRESS_INCREMENT = 500;

private final Activity context;
private final Context context;
private final boolean datePickerUseDecade;

// will receive debug output
Expand All @@ -69,7 +70,7 @@ public class DirectoryLoaderTask extends AsyncTask<QueryParameter, Integer, IDir
protected Exception mException = null;

public DirectoryLoaderTask(Activity context, boolean datePickerUseDecade, String debugPrefix) {
this.context = context;
this.context = context.getApplicationContext();
this.datePickerUseDecade = datePickerUseDecade;
String combinedDebugPrefix = debugPrefix + "-DirectoryLoaderTask";
Global.debugMemory(combinedDebugPrefix, "ctor");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ private void cmdShowDetails() {
private class TagUpdateTask extends TagTask<List<String>> {

TagUpdateTask(SelectedFiles fotos) {
super(getActivity(),R.string.tags_activity_title);
this.getWorkflow().init(getActivity(), fotos, null);
super(GalleryCursorFragment.this.getActivity(),R.string.tags_activity_title);
this.getWorkflow().init(GalleryCursorFragment.this.getActivity(), fotos, null);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private List<Tag> loadTagRepositoryItems(boolean reload) {

private class TagDeleteWithDbUpdateTask extends TagTask<List<Tag>> {
TagDeleteWithDbUpdateTask() {
super(getActivity(), R.string.delete_menu_title);
super(TagsPickerFragment.this.getActivity(), R.string.delete_menu_title);
}

@Override
Expand Down Expand Up @@ -729,7 +729,7 @@ private class TagRenameWithDbUpdateTask extends TagTask<Object> {
private final String mNewName;

TagRenameWithDbUpdateTask(String oldName, String newName) {
super(getActivity(), R.string.rename_menu_title);
super(TagsPickerFragment.this.getActivity(), R.string.rename_menu_title);
this.mOldTag = new Tag().setName(oldName);
this.mNewName = newName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import android.widget.Toast;

import java.io.Closeable;
import java.io.IOException;
import java.lang.ref.WeakReference;

import de.k3b.android.androFotoFinder.R;

Expand All @@ -36,11 +36,12 @@

abstract public class AsyncTaskWithProgressDialog<param> extends AsyncTask<param, String, Integer>
implements Closeable{
protected Activity parent;
private WeakReference<Activity> activity;

protected ProgressDialog dlg = null;
public AsyncTaskWithProgressDialog(Activity parent, int idResourceTitle) {
this.parent = parent;
dlg = new ProgressDialog(parent);
public AsyncTaskWithProgressDialog(Activity activity, int idResourceTitle) {
this.setActivity(activity);
dlg = new ProgressDialog(activity);
dlg.setTitle(idResourceTitle);
}
protected void onProgressUpdate(String... values) {
Expand All @@ -53,8 +54,11 @@ protected void onProgressUpdate(String... values) {
@Override
protected void onPostExecute(Integer itemCount) {
super.onPostExecute(itemCount);
String message = parent.getString(R.string.image_success_update_format, itemCount);
Toast.makeText(parent, message, Toast.LENGTH_LONG).show();
Activity activity = getActivity();
if (activity != null) {
String message = activity.getString(R.string.image_success_update_format, itemCount);
Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
}

destroy();
}
Expand All @@ -73,7 +77,7 @@ public void destroy() {
dlg.dismiss();
}
dlg = null;
parent = null;
setActivity(null);
}

/** periodically called while work in progress. */
Expand All @@ -92,4 +96,12 @@ protected void publishProgress(int itemCount, int total, Object message) {
publishProgress(msg.toString());
}

protected Activity getActivity() {
if (activity == null) return null;
return activity.get();
}

private void setActivity(Activity activity) {
this.activity = (activity != null) ? new WeakReference<>(activity) : null;
}
}
8 changes: 5 additions & 3 deletions app/src/main/java/de/k3b/android/widget/UpdateTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ protected void onPostExecute(Integer itemCount) {
if (Global.debugEnabled) {
Log.d(Global.LOG_CONTEXT, mDebugPrefix + " onPostExecute " + itemCount);
}
Activity parent = this.parent;
Activity parent = this.getActivity();
super.onPostExecute(itemCount);
parent.setResult(EXIF_RESULT_ID, parent.getIntent());
parent.finish();
if (parent != null) {
parent.setResult(EXIF_RESULT_ID, parent.getIntent());
parent.finish();
}
}

@Override
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
*/
-->
<resources>
<string name="about_summary">Sobre um Gerenciador de Fotos%1$s</string>
<string name="area_menu_title">Selecione a área do mapa</string>
<string name="background">Fundo</string>
<string name="about_summary">Sobre \"Um Gerenciador de Fotos%1$s\"</string>
<string name="area_menu_title">Filtro de Área de Mapa</string>
<string name="background">Plano de fundo</string>
<string name="bookmark">Álbum</string>
<string name="bookmark_delete_answer_format">Marcador deletado %1$s.</string>
<string name="bookmark_delete_error_format">O marcador não pode ser deletado %1$s.</string>
<string name="bookmark_delete_question">Deletar o marcador?</string>
<string name="bookmark_delete_answer_format">Álbum excluído %1$s.</string>
<string name="bookmark_delete_error_format">Não é possível excluir o álbum %1$s.</string>
<string name="bookmark_delete_question">Excluir este álbum?</string>
<string name="bookmark_file_comment_format">Gerado em %3$s com \'%1$s\' Versão %2$s. Veja https://github.com/k3b/APhotoManager/wiki/intentapi#sql para mais detalhes</string>
<string name="bookmark_save_as_menu_title">Salvar como &#8230;</string>
<string name="btn_change">Mudar</string>
<string name="bookmark_save_as_menu_title">Salvar álbum como &#8230;</string>
<string name="btn_change">Alterar</string>
<string name="btn_pause">Pausar</string>
<string name="copy_result_format">Arquivos %1$d/%2$d copiados</string>
<string name="delete_menu_title">Deletar</string>
<string name="copy_result_format">%1$d/%2$d arquivos copiados</string>
<string name="delete_menu_title">Excluir</string>
<string name="delete_question_message_format">"Você tem certeza de que quer deletar esses arquivos permanentemente?
%1$s

Expand Down Expand Up @@ -91,7 +91,7 @@ Não é possível \'%2$s.\'"</string>
<string name="scanner_dir_question">Onde começar a verificação?</string>
<string name="scanner_err_busy">Não é possível processar arquivos de fotos enquanto o leitor de mídia do Android estiver ocupado. Tente novamente mais tarde.</string>
<string name="scanner_menu_title">Scanner de mídia</string>
<string name="scanner_update_result_format">%1$d Itens de mídia atualizados</string>
<string name="scanner_update_result_format">Atualizado %1$d itens do banco de dados de mídia</string>
<string name="selection_status_format">%1$d Selecionado</string>
<string name="selection_none_hint">Selecione a pasta para carregar fotos e clique em ok</string>
<string name="selected_only_menu_title">Apenas selecionado</string>
Expand Down Expand Up @@ -239,4 +239,4 @@ Você pode desfazer a ocultação chamando o leitor mediascanner do menu da gale
< ! - - what type of data should be saven ? - - >
<string name="lbl_what">What: </string>
-->
</resources>
</resources>

0 comments on commit a5efcbd

Please sign in to comment.