1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-23 03:18:04 +01:00

Moved pod settings to SettingsActivity

This commit is contained in:
vanitasvitae 2016-06-18 15:53:49 +02:00
parent b8cb2d1b84
commit dbfa8692e8
9 changed files with 78 additions and 46 deletions

View file

@ -45,7 +45,7 @@
android:name=".activity.SettingsActivity"
android:launchMode="singleInstance"
android:theme="@style/AppTheme"
android:label="@string/jb_settings">
android:label="@string/pref_title_personal_settings">
</activity>
<activity

View file

@ -108,7 +108,8 @@ public class MainActivity extends AppCompatActivity
static final int INPUT_FILE_REQUEST_CODE = 1;
private static final int REQUEST_CODE_ASK_PERMISSIONS = 123;
public static final int REQUEST_CODE_ASK_PERMISSIONS_SAVE_IMAGE = 124;
private static final String URL_MESSAGE = "URL_MESSAGE";
public static final int REQUEST_CODE_SETTINGS = 125;
public static final String URL_MESSAGE = "URL_MESSAGE";
private App app;
private String podDomain;
@ -167,6 +168,7 @@ public class MainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent startIntent = getIntent();
// Bind UI
setContentView(R.layout.main__activity);
ButterKnife.bind(this);
@ -216,10 +218,11 @@ public class MainActivity extends AppCompatActivity
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary,
R.color.fab_big);
String url = "https://" + podDomain;
if (savedInstanceState == null) {
if (Helpers.isOnline(MainActivity.this)) {
webView.loadData("", "text/html", null);
webView.loadUrl("https://" + podDomain);
webView.loadUrl(url);
} else {
Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
}
@ -404,6 +407,12 @@ public class MainActivity extends AppCompatActivity
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE_SETTINGS) {
if(resultCode == Activity.RESULT_OK) {
String url = data.getStringExtra(URL_MESSAGE);
webView.loadUrl(url);
}
}
if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) {
super.onActivityResult(requestCode, resultCode, data);
return;
@ -930,29 +939,7 @@ public class MainActivity extends AppCompatActivity
break;
case R.id.nav_settings_app: {
startActivity(new Intent(this, SettingsActivity.class));
}
break;
case R.id.nav_settings_diaspora: {
final CharSequence[] options2 = {getString(R.string.jb_settings), getString(R.string.jb_manage_tags),
getString(R.string.jb_contacts)};
if (Helpers.isOnline(MainActivity.this)) {
new AlertDialog.Builder(MainActivity.this)
.setItems(options2, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (options2[item].equals(getString(R.string.jb_settings)))
webView.loadUrl("https://" + podDomain + "/user/edit");
if (options2[item].equals(getString(R.string.jb_manage_tags)))
webView.loadUrl("https://" + podDomain + "/tag_followings/manage");
if (options2[item].equals(getString(R.string.jb_contacts)))
webView.loadUrl("https://" + podDomain + "/contacts");
}
}).show();
} else {
Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
}
startActivityForResult(new Intent(this, SettingsActivity.class), REQUEST_CODE_SETTINGS);
}
break;

View file

@ -1,5 +1,6 @@
package com.github.dfa.diaspora_android.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@ -9,6 +10,7 @@ import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
@ -21,17 +23,19 @@ import com.github.dfa.diaspora_android.data.AppSettings;
*/
public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
private SharedPreferences sharedPreferences;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName("app");
addPreferencesFromResource(R.xml.preferences);
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
sharedPreferences = getPreferenceScreen().getSharedPreferences();
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
setPreferenceSummaries();
SharedPreferences preferences = getPreferenceScreen().getSharedPreferences();
preferences.edit().putBoolean(AppSettings.PREF.PROXY_WAS_ENABLED,
preferences.getBoolean(AppSettings.PREF.PROXY_ENABLED, false)).apply();
setResult(Activity.RESULT_CANCELED);
sharedPreferences.edit().putBoolean(AppSettings.PREF.PROXY_WAS_ENABLED,
sharedPreferences.getBoolean(AppSettings.PREF.PROXY_ENABLED, false)).apply();
}
private void setPreferenceSummaries() {
@ -60,4 +64,25 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
return;
}
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
Intent results = new Intent();
String podDomain = ((App)getApplication()).getSettings().getPodDomain();
switch(preference.getKey()) {
case "pref_key_personal_settings":
results.putExtra(MainActivity.URL_MESSAGE, "https://" + podDomain + "/user/edit");
setResult(Activity.RESULT_OK, results);
finish();
case "pref_key_manage_tags":
results.putExtra(MainActivity.URL_MESSAGE, "https://" + podDomain + "/tag_followings/manage");
setResult(Activity.RESULT_OK, results);
finish();
case "pref_key_manage_contacts":
results.putExtra(MainActivity.URL_MESSAGE, "https://" + podDomain + "/contacts");
setResult(Activity.RESULT_OK, results);
finish();
}
return super.onPreferenceTreeClick(screen, preference);
}
}

View file

@ -57,11 +57,6 @@
android:icon="@drawable/jb_settings"
android:title="@string/jb_settings_view" />
<item
android:id="@+id/nav_settings_diaspora"
android:icon="@drawable/jb_stream"
android:title="@string/jb_settings_diaspora" />
<item
android:id="@+id/nav_license_help"
android:icon="@drawable/jb_license"

View file

@ -3,6 +3,7 @@
<!-- Categories -->
<string name="pref_category_visuals">Erscheinungsbild</string>
<string name="pref_category_network">Netzwerk</string>
<string name="pref_category_pod_settings">Pod Einstellungen</string>
<!-- Visuals -->
<!-- Font size -->
@ -21,4 +22,10 @@
<string name="pref_title_proxy_enabled">Aktiviere Proxy</string>
<string name="pref_desc_proxy_enabled">Nutze einen Proxyserver um Firewalls zu umgehen</string>
<!-- Diaspora Settings -->
<string name="pref_title_personal_settings">Persönliche Einstellungen</string>
<string name="pref_title_manage_contacts">Kontakte</string>
<string name="pref_title_manage_tags">Tags verwalten</string>
<string name="pref_title_change_pod">Pod wechseln</string>
</resources>

View file

@ -46,14 +46,10 @@
<string name="jb_stream">Stream</string>
<string name="jb_liked">Gelikte Beiträge</string>
<string name="jb_commented">Kommentierte Beiträge</string>
<string name="jb_contacts">Kontakte</string>
<string name="jb_mentions">Erwähnungen</string>
<string name="jb_activities">Aktivitäten</string>
<string name="jb_followed_tags">Verfolgte Tags</string>
<string name="jb_manage_tags">Tags verwalten</string>
<string name="jb_settings">Persönliche Einstellungen</string>
<string name="jb_aspects">Aspekte</string>
<string name="jb_pod">Pod wechseln</string>
<string name="jb_public">Öffentliche Aktivitäten</string>
// Floating Action Buttons - Titles
@ -85,7 +81,6 @@
<string name="share_screenshot">Bildschirmfoto teilen</string>
<string name="take_screenshot">Bildschirmfoto speichern</string>
<string name="toast_screenshot">Bildschirmfoto wird gespeichert unter:</string>
<string name="jb_settings_diaspora">Pod Einstellungen</string>
<string name="jb_settings_view">App Einstellungen</string>
<string name="help_help">Markdown Formatierung</string>
<string name="help_license">Lizenz</string>

View file

@ -3,6 +3,7 @@
<!-- Categories -->
<string name="pref_category_visuals">Appearance</string>
<string name="pref_category_network">Network</string>
<string name="pref_category_pod_settings">Pod settings</string>
<!-- Visuals -->
<!-- Font size -->
@ -29,4 +30,10 @@
<string name="pref_title_proxy_host" translatable="false">Host</string>
<string name="pref_title_proxy_port" translatable="false">Port</string>
<!-- Diaspora Settings -->
<string name="pref_title_personal_settings">Personal settings</string>
<string name="pref_title_manage_contacts">Contacts</string>
<string name="pref_title_manage_tags">Manage Hashtags</string>
<string name="pref_title_change_pod">Change pod</string>
</resources>

View file

@ -61,17 +61,12 @@
<string name="jb_stream">Stream</string>
<string name="jb_liked">Liked</string>
<string name="jb_commented">Commented</string>
<string name="jb_contacts">Contacts</string>
<string name="jb_mentions">Mentions</string>
<string name="jb_activities">Activities</string>
<string name="jb_followed_tags">Followed Hashtags</string>
<string name="jb_manage_tags">Manage Hashtags</string>
<string name="jb_settings">Personal settings</string>
<string name="jb_aspects">Aspects</string>
<string name="jb_pod">Change pod</string>
<string name="jb_public">Public activities</string>
<string name="jb_settings_view">App settings</string>
<string name="jb_settings_diaspora">Pod settings</string>
<string name="jb_share">Share content</string>
<string name="settings_font">Change font size</string>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Appearance -->
<PreferenceCategory
android:title="@string/pref_category_visuals"
android:key="pref_key_category_visuals">
@ -12,6 +13,27 @@
android:entryValues="@array/pref_entry_values_font_size" />
</PreferenceCategory>
<!-- Diaspora Pod Settings -->
<PreferenceCategory
android:title="@string/pref_category_pod_settings"
android:key="pref_key_category_pod_settings">
<Preference
android:title="@string/pref_title_personal_settings"
android:key="pref_key_personal_settings">
</Preference>
<Preference
android:title="@string/pref_title_manage_tags"
android:key="pref_key_manage_tags">
</Preference>
<Preference
android:title="@string/pref_title_manage_contacts"
android:key="pref_key_manage_contacts">
</Preference>
</PreferenceCategory>
<!-- Networking -->
<PreferenceCategory
android:title="@string/pref_category_network"
android:key="pref_key_category_network">
@ -37,5 +59,4 @@
android:dependency="pref_key_proxy_enabled"
android:inputType="number" />
</PreferenceCategory>
</PreferenceScreen>