diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 976a17731839f1bc638b74c0d3e1bfd8742e2d00..753b9522726193ff83991b94b005b72e2fb7295b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -102,7 +102,7 @@ </activity> <activity android:name=".addressbook.AddressbookSettingsActivity" - android:label="I2P Addressbook Settings" + android:label="Addressbook Settings" android:launchMode="singleTop" android:parentActivityName=".addressbook.AddressbookActivity"> <meta-data diff --git a/app/src/main/java/net/i2p/android/router/SettingsActivity.java b/app/src/main/java/net/i2p/android/router/SettingsActivity.java index 564c629200d571e8674ca795a27adfb1f92a4222..be9d687dcbfd574e47686a2033052e9c4c7ffcdd 100644 --- a/app/src/main/java/net/i2p/android/router/SettingsActivity.java +++ b/app/src/main/java/net/i2p/android/router/SettingsActivity.java @@ -9,6 +9,10 @@ import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; import android.widget.Toast; import net.i2p.I2PAppContext; @@ -33,6 +37,8 @@ public class SettingsActivity extends PreferenceActivity { private static final String ACTION_PREFS_LOGGING = "net.i2p.android.router.PREFS_LOGGING"; private static final String ACTION_PREFS_ADVANCED = "net.i2p.android.router.PREFS_ADVANCED"; + private Toolbar mToolbar; + @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { @@ -55,6 +61,8 @@ public class SettingsActivity extends PreferenceActivity { // Load the legacy preferences headers addPreferencesFromResource(R.xml.settings_headers_legacy); } + + mToolbar.setTitle(getTitle()); } protected static void setupGraphSettings(Context context, PreferenceScreen ps, RouterContext ctx) { @@ -155,6 +163,25 @@ public class SettingsActivity extends PreferenceActivity { loadHeadersFromResource(R.xml.settings_headers, target); } + @Override + public void setContentView(int layoutResID) { + ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate( + R.layout.activity_settings, + (ViewGroup) getWindow().getDecorView().getRootView(), false); + mToolbar = (Toolbar) contentView.findViewById(R.id.main_toolbar); + mToolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper); + LayoutInflater.from(this).inflate(layoutResID, contentWrapper, true); + + getWindow().setContentView(contentView); + } + @Override protected void onPause() { List<Properties> lProps = Util.getPropertiesFromPreferences(this); diff --git a/app/src/main/java/net/i2p/android/router/addressbook/AddressbookSettingsActivity.java b/app/src/main/java/net/i2p/android/router/addressbook/AddressbookSettingsActivity.java index 36048ec0168d1fb39a67fb1f9aad1ecfc37205bb..a9ae224f964687b38ea6b3cb548eeaf1a191827c 100644 --- a/app/src/main/java/net/i2p/android/router/addressbook/AddressbookSettingsActivity.java +++ b/app/src/main/java/net/i2p/android/router/addressbook/AddressbookSettingsActivity.java @@ -1,20 +1,22 @@ package net.i2p.android.router.addressbook; -import android.app.Activity; import android.content.Context; import android.os.Bundle; -import android.view.Menu; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; + +import net.i2p.android.router.R; +import net.i2p.util.FileUtil; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import net.i2p.android.router.R; -import net.i2p.util.FileUtil; -public class AddressbookSettingsActivity extends Activity { +public class AddressbookSettingsActivity extends ActionBarActivity { private EditText text_content_subscriptions; private Button btn_save_subscriptions; @@ -25,6 +27,11 @@ public class AddressbookSettingsActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_addressbook_settings); + + // Set the action bar + Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); + setSupportActionBar(toolbar); + text_content_subscriptions = (EditText) findViewById(R.id.subscriptions_content); btn_save_subscriptions = (Button) findViewById(R.id.button_save_subscriptions); init_actions(); @@ -32,12 +39,6 @@ public class AddressbookSettingsActivity extends Activity { load(); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.activity_addressbook_settings, menu); - return true; - } - private void init_actions() { btn_save_subscriptions.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { diff --git a/app/src/main/res/layout/activity_addressbook_settings.xml b/app/src/main/res/layout/activity_addressbook_settings.xml index de157228780e1f4176cad3e1b55648e270e8d006..cba39c9b370db3af2e759827e498c8928ac57299 100644 --- a/app/src/main/res/layout/activity_addressbook_settings.xml +++ b/app/src/main/res/layout/activity_addressbook_settings.xml @@ -1,48 +1,59 @@ <?xml version="1.0" encoding="utf-8"?> -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:fillViewport="true" - android:padding="10px" - android:scrollbarStyle="outsideInset" - > - <LinearLayout +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.Toolbar + android:id="@+id/main_toolbar" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" > + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + android:minHeight="?attr/actionBarSize" + app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> - <TextView - android:id="@+id/textView1" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="Addressbook Settings" - android:textAppearance="?android:attr/textAppearanceLarge" /> + <ScrollView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginBottom="@dimen/activity_vertical_margin" + android:layout_marginEnd="@dimen/activity_horizontal_margin" + android:layout_marginLeft="@dimen/activity_horizontal_margin" + android:layout_marginRight="@dimen/activity_horizontal_margin" + android:layout_marginStart="@dimen/activity_horizontal_margin" + android:layout_marginTop="@dimen/activity_vertical_margin" + android:fillViewport="true" + android:scrollbarStyle="outsideInset"> - <TextView - android:id="@+id/textView2" - android:layout_width="wrap_content" + <LinearLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="Subscriptions" - android:textAppearance="?android:attr/textAppearanceMedium" /> + android:orientation="vertical"> - <EditText - android:id="@+id/subscriptions_content" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="textMultiLine" - android:maxLines="@integer/min_lines" - android:minLines="@integer/min_lines" > + <TextView + android:id="@+id/textView2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Subscriptions" + android:textAppearance="?android:attr/textAppearanceMedium" /> - <requestFocus /> - </EditText> + <EditText + android:id="@+id/subscriptions_content" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:ems="10" + android:inputType="textMultiLine"> - <Button - android:id="@+id/button_save_subscriptions" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="Save subscriptions.txt" /> + <requestFocus /> + </EditText> + + <Button + android:id="@+id/button_save_subscriptions" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Save subscriptions.txt" /> - </LinearLayout> + </LinearLayout> -</ScrollView> + </ScrollView> +</LinearLayout> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..452bb3dd0f41ca3f8f4535c7e8f970d3373644ff --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.Toolbar + android:id="@+id/main_toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + android:minHeight="?attr/actionBarSize" + app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> + + <FrameLayout + android:id="@+id/content_wrapper" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/menu/activity_addressbook_settings.xml b/app/src/main/res/menu/activity_addressbook_settings.xml deleted file mode 100644 index 44a11e7db01bbbaa8925eb0bc694ee17636069fb..0000000000000000000000000000000000000000 --- a/app/src/main/res/menu/activity_addressbook_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:id="@+id/menu_settings" - android:title="@string/menu_settings" - android:orderInCategory="100" /> -</menu>