mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Allow for customized Background image #50
This commit is contained in:
@@ -41,8 +41,14 @@
|
||||
<string name="ApplicationPreferencesActivity_sms_mms_summary">SMS %1$s, MMS %2$s</string>
|
||||
<string name="ApplicationPreferencesActivity_privacy_summary">Screen lock %1$s, Read receipts %2$s</string>
|
||||
<string name="ApplicationPreferencesActivity_appearance_summary">Theme %1$s, Language %2$s</string>
|
||||
<string name="ApplicationPreferencesActivity_appearance_summary_new">Theme %1$s, Language %2$s, Background %3$s</string>
|
||||
<string name="ApplicationPreferencesActivity_appearance_background_default">default</string>
|
||||
<string name="ApplicationPreferencesActivity_appearance_background_custom">custom</string>
|
||||
|
||||
<!-- AppearancePreferenceFragment -->
|
||||
<string name="AppearancePreferencesFragment_background_save_error">Background image could not be saved</string>
|
||||
<string name="AppearancePreferencesFragment_background_custom_summary">Custom</string>
|
||||
<string name="AppearancePreferencesFragment_background_default_summary">Default</string>
|
||||
|
||||
<!-- AppProtectionPreferenceFragment -->
|
||||
<plurals name="AppProtectionPreferenceFragment_minutes">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
android:entryValues="@array/language_values"
|
||||
android:defaultValue="zz"/>
|
||||
|
||||
<Preference
|
||||
<org.thoughtcrime.securesms.preferences.widgets.SignalPreference
|
||||
android:key="pref_chat_background"
|
||||
android:title="@string/preferences__chat_background"
|
||||
/>
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -41,6 +42,15 @@ public class AppearancePreferenceFragment extends ListSummaryPreferenceFragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__appearance);
|
||||
String imagePath = TextSecurePreferences.getBackgroundImagePath(getContext());
|
||||
String backgroundString;
|
||||
if(imagePath.isEmpty()){
|
||||
backgroundString = this.getString(R.string.AppearancePreferencesFragment_background_default_summary);
|
||||
}
|
||||
else{
|
||||
backgroundString = this.getString(R.string.AppearancePreferencesFragment_background_custom_summary);
|
||||
}
|
||||
this.findPreference(TextSecurePreferences.BACKGROUND_PREF).setSummary(backgroundString);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,9 +71,18 @@ public class AppearancePreferenceFragment extends ListSummaryPreferenceFragment
|
||||
if (langIndex == -1) langIndex = 0;
|
||||
if (themeIndex == -1) themeIndex = 0;
|
||||
|
||||
return context.getString(R.string.ApplicationPreferencesActivity_appearance_summary,
|
||||
String imagePath = TextSecurePreferences.getBackgroundImagePath(context);
|
||||
String backgroundString;
|
||||
if(imagePath.isEmpty()){
|
||||
backgroundString = context.getString(R.string.ApplicationPreferencesActivity_appearance_background_default);
|
||||
}
|
||||
else{
|
||||
backgroundString = context.getString(R.string.ApplicationPreferencesActivity_appearance_background_custom);
|
||||
}
|
||||
|
||||
return context.getString(R.string.ApplicationPreferencesActivity_appearance_summary_new,
|
||||
themeEntries[themeIndex],
|
||||
languageEntries[langIndex]);
|
||||
languageEntries[langIndex], backgroundString);
|
||||
}
|
||||
|
||||
private class BackgroundClickListener implements Preference.OnPreferenceClickListener {
|
||||
|
||||
@@ -86,8 +86,8 @@ public class ChatBackgroundActivity extends BaseActionBarActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
String destination = context.getFilesDir().getAbsolutePath() + "/background";
|
||||
scaleAndSaveImage(context, destination);
|
||||
TextSecurePreferences.setBackgroundImagePath(context, destination);
|
||||
scaleAndSaveImage(context, destination);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
@@ -123,12 +123,15 @@ public class ChatBackgroundActivity extends BaseActionBarActivity {
|
||||
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 85, outStream);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
TextSecurePreferences.setBackgroundImagePath(context, "");
|
||||
showBackgroundSaveError();
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
TextSecurePreferences.setBackgroundImagePath(context, "");
|
||||
showBackgroundSaveError();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
TextSecurePreferences.setBackgroundImagePath(context, "");
|
||||
showBackgroundSaveError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user