Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Kp2aBusinessLogic/database/CheckDatabaseForChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace keepass2android
{
public class CheckDatabaseForChanges : OperationWithFinishHandler
{
private readonly Context _context;
private readonly IKp2aApp _app;


Expand Down Expand Up @@ -66,7 +65,7 @@ public override void Run()

if (!MemUtil.ArraysEqual(_app.CurrentDb.KpDatabase.HashOfFileOnDisk, hashingRemoteStream.Hash))
{
_app.TriggerReload(_context, null);
_app.TriggerReload(null, null);
Finish(true);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,15 @@ public void onConfigurationChanged(Configuration conf) {
// locale (mSystemLocale), then reload the input locale list from the
// latin ime settings (shared prefs) and reset the input locale
// to the first one.
final String systemLocale = conf.locale.toString();
final Locale configLocale = conf.locale != null ? conf.locale
: (conf.getLocales().size() > 0 ? conf.getLocales().get(0) : Locale.getDefault());
final String systemLocale = configLocale.toString();
if (!TextUtils.equals(systemLocale, mSystemLocale)) {
mSystemLocale = systemLocale;
if (mLanguageSwitcher != null) {
mLanguageSwitcher.loadLocales(
PreferenceManager.getDefaultSharedPreferences(this));
mLanguageSwitcher.setSystemLocale(conf.locale);
mLanguageSwitcher.setSystemLocale(configLocale);
toggleLanguage(true, true);
} else {
reloadKeyboards();
Expand Down
17 changes: 15 additions & 2 deletions src/keepass2android-app/app/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ public void UpdateOngoingNotification()
var ctx = LocaleManager.LocalizedAppContext;
if (DatabaseIsUnlocked || QuickLocked)
{
ContextCompat.StartForegroundService(ctx, new Intent(ctx, typeof(OngoingNotificationsService)));
try
{
ContextCompat.StartForegroundService(ctx, new Intent(ctx, typeof(OngoingNotificationsService)));
}
catch (Exception e)
{
// ForegroundServiceStartNotAllowedException (Android 12+): startForegroundService() is
// not allowed when called from a background-restricted context such as onTaskRemoved().
// In this case the notification simply cannot be updated; this is acceptable.
Kp2aLog.LogUnexpectedError(e);
}
}
else
{
Expand Down Expand Up @@ -1023,7 +1033,10 @@ public void TriggerReload(Context ctx, Action<bool> actionOnResult)
Handler handler = new Handler(Looper.MainLooper);
handler.Post(() =>
{
AskForReload((Activity)ctx, actionOnResult);
var activity = (ctx as Activity) ?? (ActiveContext as Activity);
if (activity == null)
return;
AskForReload(activity, actionOnResult);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/services/BackgroundSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void OnCreate()

public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
if (intent.Action == ActionStop)
if (intent?.Action == ActionStop)
{
Log.Debug(Tag, "OnStartCommand: STOP");
StopForeground(StopForegroundFlags.Remove);
Expand Down
4 changes: 3 additions & 1 deletion src/keepass2android-app/views/GroupListItemView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public override bool Activated

public void SetRightArrowVisibility(bool visible)
{
FindViewById(Resource.Id.right_arrow).Visibility = visible ? ViewStates.Visible : ViewStates.Invisible;
var arrow = FindViewById(Resource.Id.right_arrow);
if (arrow != null)
arrow.Visibility = visible ? ViewStates.Visible : ViewStates.Invisible;
}

public abstract void OnClick();
Expand Down
4 changes: 2 additions & 2 deletions src/keepass2android-app/views/PwEntryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ private PwEntryView(GroupBaseActivity groupActivity, PwEntry pw, int pos) : base
_textView = (TextView)ev.FindViewById(Resource.Id.entry_text);
_textView.TextSize = PrefsUtil.GetListTextSize(groupActivity);

Database db = App.Kp2a.FindDatabaseForElement(pw);
Database db = App.Kp2a.TryFindDatabaseForElement(pw);

ev.FindViewById(Resource.Id.entry_icon_bkg).Visibility = db.DrawableFactory.IsWhiteIconSet ? ViewStates.Visible : ViewStates.Gone;
ev.FindViewById(Resource.Id.entry_icon_bkg).Visibility = db?.DrawableFactory.IsWhiteIconSet == true ? ViewStates.Visible : ViewStates.Gone;

_textviewDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail);
_textviewDetails.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity);
Expand Down
Loading