using preferenceactivity and added custom refresh itnerval option
This commit is contained in:
@@ -17,7 +17,6 @@ The main purpose of me building this app is to practice usage of Square's Dagger
|
||||
|
||||
## Future versions
|
||||
*Future versions will include:*
|
||||
- Ability to set a custom refresh interval
|
||||
- Ability to pick indices such as **^DJI**.
|
||||
- Ability to change the app theme and colors
|
||||
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.github.premnirmal.tickerwidget"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 21
|
||||
versionCode 25
|
||||
versionName "4.20.00"
|
||||
versionCode 26
|
||||
versionName "4.30.00"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -50,6 +50,6 @@ dependencies {
|
||||
compile 'joda-time:joda-time:2.6'
|
||||
compile 'de.greenrobot:eventbus:2.4.0'
|
||||
compile 'com.github.developerpaul123.filepickerlibrary:library:1.+'
|
||||
|
||||
compile 'com.jjoe64:graphview:4.0.0'
|
||||
compile 'com.android.support:support-v4:21.0.2'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.premnirmal.tickerwidget">
|
||||
package="com.github.premnirmal.tickerwidget" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
@@ -12,10 +12,11 @@
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.github.premnirmal.ticker.ui.ParanormalActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait" >
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -23,22 +24,17 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.github.premnirmal.ticker.ui.TickerSelectorActivity"
|
||||
android:label="@string/add_ticker" />
|
||||
|
||||
<activity
|
||||
android:name="com.github.premnirmal.ticker.settings.SettingsActivity"
|
||||
android:label="@string/action_Settings" />
|
||||
|
||||
android:label="@string/add_ticker"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name="com.github.premnirmal.ticker.ui.GraphActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
|
||||
<receiver
|
||||
android:name="com.github.premnirmal.ticker.UpdateReceiver"
|
||||
android:enabled="true">
|
||||
android:enabled="true" >
|
||||
<intent-filter>
|
||||
<action android:name="com.github.premnirmal.ticker.UPDATE" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
@@ -46,13 +42,13 @@
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="com.github.premnirmal.ticker.widget.StockWidget"
|
||||
android:label="@string/widget_label">
|
||||
android:label="@string/widget_label" >
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget" />
|
||||
@@ -61,6 +57,12 @@
|
||||
<service
|
||||
android:name="com.github.premnirmal.ticker.widget.RemoteStockProviderService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
|
||||
<activity
|
||||
android:name="com.github.premnirmal.ticker.settings.SettingsActivity"
|
||||
android:label="@string/title_activity_settings_activity2"
|
||||
>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.github.premnirmal.ticker;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Environment;
|
||||
@@ -23,9 +24,10 @@ import java.util.List;
|
||||
public final class Tools {
|
||||
|
||||
public static final String PREFS_NAME = "com.github.premnirmal.ticker";
|
||||
public static final String FONT_SIZE = "com.github.premnirmal.ticker.fontsize";
|
||||
public static final String FONT_SIZE = "com.github.premnirmal.ticker.textsize";
|
||||
public static final String SETTING_AUTOSORT = "SETTING_AUTOSORT";
|
||||
public static final String WIDGET_BG = "WIDGET_BG";
|
||||
public static final String UPDATE_INTERVAL = "UPDATE_INTERVAL";
|
||||
public static final int TRANSPARENT = 0;
|
||||
public static final int TRANSLUCENT = 1;
|
||||
|
||||
@@ -36,8 +38,17 @@ public final class Tools {
|
||||
}
|
||||
|
||||
public static float getFontSize(Context context) {
|
||||
return context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
.getInt(FONT_SIZE, context.getResources().getInteger(R.integer.text_size_medium));
|
||||
final int size = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
.getInt(FONT_SIZE, 1);
|
||||
switch (size) {
|
||||
case 0:
|
||||
return context.getResources().getInteger(R.integer.text_size_small);
|
||||
case 2:
|
||||
return context.getResources().getInteger(R.integer.text_size_large);
|
||||
case 1:
|
||||
default:
|
||||
return context.getResources().getInteger(R.integer.text_size_medium);
|
||||
}
|
||||
}
|
||||
|
||||
public static File getTickersFile() {
|
||||
@@ -72,7 +83,9 @@ public final class Tools {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getMsToNextAlarm() {
|
||||
public static long getMsToNextAlarm(Context context) {
|
||||
final SharedPreferences preferences = context.getSharedPreferences(Tools.PREFS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
final int hourOfDay = DateTime.now().hourOfDay().get();
|
||||
final int dayOfWeek = DateTime.now().getDayOfWeek();
|
||||
final MutableDateTime mutableDateTime = new MutableDateTime(DateTime.now());
|
||||
@@ -101,12 +114,13 @@ public final class Tools {
|
||||
mutableDateTime.setHourOfDay(9); // 9am
|
||||
mutableDateTime.setMinuteOfHour(15); // update at 9:15am
|
||||
}
|
||||
|
||||
final int updatePref = preferences.getInt(UPDATE_INTERVAL,1);
|
||||
final long time = AlarmManager.INTERVAL_FIFTEEN_MINUTES * (updatePref + 1);
|
||||
if (set) {
|
||||
final long msToNextSchedule = mutableDateTime.getMillis() - DateTime.now().getMillis();
|
||||
return SystemClock.elapsedRealtime() + msToNextSchedule;
|
||||
} else {
|
||||
return SystemClock.elapsedRealtime() + (AlarmManager.INTERVAL_FIFTEEN_MINUTES * 2);
|
||||
return SystemClock.elapsedRealtime() + time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ public class StocksProvider implements IStocksProvider {
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
|
||||
context.sendBroadcast(intent);
|
||||
bus.post(new StockUpdatedEvent());
|
||||
scheduleUpdate(Tools.getMsToNextAlarm());
|
||||
scheduleUpdate(Tools.getMsToNextAlarm(context));
|
||||
}
|
||||
|
||||
private void scheduleUpdate(long msToNextAlarm) {
|
||||
|
||||
@@ -2,18 +2,18 @@ package com.github.premnirmal.ticker.network;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.github.premnirmal.ticker.UpdateReceiver;
|
||||
import com.github.premnirmal.ticker.model.HistoryProvider;
|
||||
import com.github.premnirmal.ticker.model.IHistoryProvider;
|
||||
import com.github.premnirmal.ticker.ui.GraphActivity;
|
||||
import com.github.premnirmal.tickerwidget.R;
|
||||
import com.github.premnirmal.ticker.UpdateReceiver;
|
||||
import com.github.premnirmal.ticker.model.IStocksProvider;
|
||||
import com.github.premnirmal.ticker.model.StocksProvider;
|
||||
import com.github.premnirmal.ticker.settings.SettingsActivity;
|
||||
import com.github.premnirmal.ticker.ui.GraphActivity;
|
||||
import com.github.premnirmal.ticker.ui.ParanormalActivity;
|
||||
import com.github.premnirmal.ticker.ui.TickerSelectorActivity;
|
||||
import com.github.premnirmal.ticker.widget.RemoteStockViewAdapter;
|
||||
import com.github.premnirmal.ticker.widget.StockWidget;
|
||||
import com.github.premnirmal.tickerwidget.R;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@ import android.app.AlertDialog;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.devpaul.filepickerlibrary.FilePickerActivity;
|
||||
import com.github.premnirmal.ticker.BaseActivity;
|
||||
import com.github.premnirmal.ticker.StocksApp;
|
||||
import com.github.premnirmal.ticker.Tools;
|
||||
import com.github.premnirmal.ticker.model.IStocksProvider;
|
||||
@@ -28,9 +28,9 @@ import com.github.premnirmal.tickerwidget.R;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created by premnirmal on 12/22/14.
|
||||
* Created by premnirmal on 01/09/15.
|
||||
*/
|
||||
public class SettingsActivity extends BaseActivity {
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
@Inject
|
||||
IStocksProvider stocksProvider;
|
||||
@@ -39,10 +39,21 @@ public class SettingsActivity extends BaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
((StocksApp) getApplicationContext()).inject(this);
|
||||
setContentView(R.layout.activity_preferences);
|
||||
}
|
||||
|
||||
final SharedPreferences preferences = getSharedPreferences(Tools.PREFS_NAME, Context.MODE_PRIVATE);
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
final Toolbar bar = (Toolbar) findViewById(R.id.toolbar);
|
||||
bar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
((TextView) findViewById(R.id.version)).setText("Version " + BuildConfig.VERSION_NAME);
|
||||
|
||||
setContentView(R.layout.activity_settings);
|
||||
findViewById(R.id.action_export).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -69,102 +80,101 @@ public class SettingsActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
final CheckBox autoSortCheckbox = (CheckBox) findViewById(R.id.autosort_checkbox);
|
||||
autoSortCheckbox.setChecked(preferences.getBoolean(Tools.SETTING_AUTOSORT, false));
|
||||
autoSortCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
setupSimplePreferencesScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the simplified settings UI if the device configuration if the
|
||||
* device configuration dictates that a simplified, single-pane UI should be
|
||||
* shown.
|
||||
*/
|
||||
private void setupSimplePreferencesScreen() {
|
||||
// In the simplified UI, fragments are not used at all and we instead
|
||||
// use the older PreferenceActivity APIs.
|
||||
|
||||
// Add 'general' preferences.
|
||||
addPreferencesFromResource(R.xml.prefs);
|
||||
|
||||
final SharedPreferences preferences = getSharedPreferences(Tools.PREFS_NAME, Context.MODE_PRIVATE);
|
||||
|
||||
final ListPreference fontSizePreference = (ListPreference) findPreference(Tools.FONT_SIZE);
|
||||
final int size = preferences.getInt(Tools.FONT_SIZE, 1);
|
||||
fontSizePreference.setValueIndex(size);
|
||||
fontSizePreference.setSummary(fontSizePreference.getEntries()[size]);
|
||||
fontSizePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
preferences.edit().putBoolean(Tools.SETTING_AUTOSORT, isChecked).commit();
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
final String stringValue = value.toString();
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
final int index = listPreference.findIndexOfValue(stringValue);
|
||||
preferences.edit().remove(Tools.FONT_SIZE).putInt(Tools.FONT_SIZE, index).commit();
|
||||
broadcastUpdateWidget();
|
||||
fontSizePreference.setSummary(fontSizePreference.getEntries()[index]);
|
||||
Toast.makeText(SettingsActivity.this, R.string.text_size_updated_message, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.change_text_size).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SharedPreferences preferences = getSharedPreferences(Tools.PREFS_NAME, MODE_PRIVATE);
|
||||
final ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(SettingsActivity.this, R.array.font_sizes, R.layout.textview);
|
||||
final AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final int fontSizeDimen;
|
||||
switch (position) {
|
||||
case 1:
|
||||
fontSizeDimen = R.integer.text_size_medium;
|
||||
break;
|
||||
case 2:
|
||||
fontSizeDimen = R.integer.text_size_large;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
fontSizeDimen = R.integer.text_size_small;
|
||||
break;
|
||||
}
|
||||
final int fontSize = getResources().getInteger(fontSizeDimen);
|
||||
preferences.edit().remove(Tools.FONT_SIZE).putInt(Tools.FONT_SIZE, fontSize).commit();
|
||||
broadcastUpdateWidget();
|
||||
Toast.makeText(SettingsActivity.this, R.string.text_size_updated_message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
createListDialog(arrayAdapter, onItemClickListener).show();
|
||||
|
||||
final ListPreference bgPreference = (ListPreference) findPreference(Tools.WIDGET_BG);
|
||||
final int bgIndex = preferences.getInt(Tools.WIDGET_BG, 0);
|
||||
bgPreference.setValueIndex(bgIndex);
|
||||
bgPreference.setSummary(bgPreference.getEntries()[bgIndex]);
|
||||
bgPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
final String stringValue = value.toString();
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
final int index = listPreference.findIndexOfValue(stringValue);
|
||||
preferences.edit().putInt(Tools.WIDGET_BG, index).commit();
|
||||
broadcastUpdateWidget();
|
||||
bgPreference.setSummary(bgPreference.getEntries()[index]);
|
||||
Toast.makeText(SettingsActivity.this, R.string.bg_updated_message, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.change_widget_background).setOnClickListener(new View.OnClickListener() {
|
||||
final ListPreference refreshPreference = (ListPreference) findPreference(Tools.UPDATE_INTERVAL);
|
||||
final int refreshIndex = preferences.getInt(Tools.UPDATE_INTERVAL, 1);
|
||||
refreshPreference.setValueIndex(refreshIndex);
|
||||
refreshPreference.setSummary(refreshPreference.getEntries()[refreshIndex]);
|
||||
refreshPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SharedPreferences preferences = getSharedPreferences(Tools.PREFS_NAME, MODE_PRIVATE);
|
||||
final ArrayAdapter<String> arrayAdapter =
|
||||
new ArrayAdapter<>(SettingsActivity.this, R.layout.textview, new String[]{"Transparent", "Translucent"});
|
||||
final AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == 0) { // transparent
|
||||
preferences.edit().putInt(Tools.WIDGET_BG, Tools.TRANSPARENT).commit();
|
||||
} else { // translucent
|
||||
preferences.edit().putInt(Tools.WIDGET_BG, Tools.TRANSLUCENT).commit();
|
||||
}
|
||||
broadcastUpdateWidget();
|
||||
Toast.makeText(SettingsActivity.this, R.string.bg_updated_message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
createListDialog(arrayAdapter, onItemClickListener).show();
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
final String stringValue = value.toString();
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
final int index = listPreference.findIndexOfValue(stringValue);
|
||||
preferences.edit().putInt(Tools.UPDATE_INTERVAL, index).commit();
|
||||
broadcastUpdateWidget();
|
||||
refreshPreference.setSummary(refreshPreference.getEntries()[index]);
|
||||
Toast.makeText(SettingsActivity.this, R.string.refresh_updated_message, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
((TextView) findViewById(R.id.version)).setText("Version " + BuildConfig.VERSION_NAME);
|
||||
final CheckBoxPreference autoSortPreference = (CheckBoxPreference) findPreference(Tools.SETTING_AUTOSORT);
|
||||
final boolean autoSort = preferences.getBoolean(Tools.SETTING_AUTOSORT, false);
|
||||
autoSortPreference.setChecked(autoSort);
|
||||
autoSortPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
final boolean checked = (boolean) value;
|
||||
preferences.edit().putBoolean(Tools.SETTING_AUTOSORT, checked).commit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void broadcastUpdateWidget() {
|
||||
final Intent intent = new Intent(getApplicationContext(), StockWidget.class);
|
||||
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
// Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
|
||||
// since it seems the onUpdate() is only fired on that:
|
||||
AppWidgetManager widgetManager = AppWidgetManager.getInstance(getApplicationContext());
|
||||
int[] ids = widgetManager.getAppWidgetIds(new ComponentName(getApplicationContext(), StockWidget.class));
|
||||
final AppWidgetManager widgetManager = AppWidgetManager.getInstance(getApplicationContext());
|
||||
final int[] ids = widgetManager.getAppWidgetIds(new ComponentName(getApplicationContext(), StockWidget.class));
|
||||
widgetManager.notifyAppWidgetViewDataChanged(ids, android.R.id.list);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private AlertDialog createListDialog(ArrayAdapter arrayAdapter, final AdapterView.OnItemClickListener onItemClickListener) {
|
||||
final ListView view = new ListView(SettingsActivity.this);
|
||||
final int padding = (int) getResources().getDimension(R.dimen.text_padding);
|
||||
view.setPadding(padding, padding, padding, padding);
|
||||
view.setAdapter(arrayAdapter);
|
||||
final AlertDialog dialog = new AlertDialog.Builder(SettingsActivity.this)
|
||||
.setView(view)
|
||||
.create();
|
||||
view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
onItemClickListener.onItemClick(parent, view, position, id);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == FilePickerActivity.REQUEST_FILE
|
||||
@@ -177,7 +187,6 @@ public class SettingsActivity extends BaseActivity {
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (result) {
|
||||
showDialog(getString(R.string.ticker_import_success));
|
||||
finish();
|
||||
} else {
|
||||
showDialog(getString(R.string.ticker_import_fail));
|
||||
}
|
||||
@@ -187,4 +196,16 @@ public class SettingsActivity extends BaseActivity {
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private void showDialog(String message) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setNeutralButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,12 @@ public class GraphActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showDialog(getString(R.string.no_network_message));
|
||||
showDialog(getString(R.string.no_network_message), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
loadGraph();
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/toolbar"
|
||||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:navigationContentDescription="@string/abc_action_bar_up_description"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:navigationIcon="?attr/homeAsUpIndicator"
|
||||
app:title="@string/action_Settings"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textSize="18dp"
|
||||
android:text="@string/action_import"
|
||||
android:id="@+id/action_import"/>
|
||||
|
||||
<include layout="@layout/divider"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textSize="18dp"
|
||||
android:text="@string/action_export"
|
||||
android:id="@+id/action_export"/>
|
||||
|
||||
<include layout="@layout/divider"/>
|
||||
|
||||
|
||||
<!-- Show Preference in ListView -->
|
||||
|
||||
<ListView
|
||||
android:id="@+id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</ListView>
|
||||
|
||||
<!-- Footer -->
|
||||
|
||||
<include layout="@layout/divider"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textSize="16dp"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:id="@+id/version"/>
|
||||
|
||||
<include layout="@layout/divider"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textSize="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/checkout_open_source"
|
||||
android:id="@+id/github_link"
|
||||
android:linksClickable="true"
|
||||
android:autoLink="all"/>
|
||||
|
||||
<include layout="@layout/divider"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,97 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/text_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/action_import"
|
||||
android:id="@+id/action_import" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/action_export"
|
||||
android:id="@+id/action_export" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/text_size"
|
||||
android:id="@+id/change_text_size" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/widget_bg"
|
||||
android:id="@+id/change_widget_background" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/auto_sort" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/abc_btn_check_material"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/autosort_checkbox"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/checkout_open_source"
|
||||
android:id="@+id/github_link"
|
||||
android:linksClickable="true"
|
||||
android:autoLink="all" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:id="@+id/version"
|
||||
android:linksClickable="true"
|
||||
android:autoLink="all" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
<string name="app_name">StockTicker</string>
|
||||
<string name="hello_world">Portfolio</string>
|
||||
<string name="version">Version</string>
|
||||
<string name="action_add">Add</string>
|
||||
<string name="action_export">Export Tickers</string>
|
||||
<string name="action_import">Import Tickers</string>
|
||||
@@ -12,14 +13,17 @@
|
||||
<string name="endpoint">http://query.yahooapis.com/v1/public</string>
|
||||
<string name="suggestions_endpoint">http://d.yimg.com/autoc.finance.yahoo.com</string>
|
||||
<string name="add_ticker">Add Ticker</string>
|
||||
<string name="dotdotdot">...</string>
|
||||
<string name="dotdotdot"> ... </string>
|
||||
<string name="text_size">Text Size</string>
|
||||
<string name="widget_bg">Widget Background</string>
|
||||
<string name="update_interval">Update Interval</string>
|
||||
<string name="auto_sort">Sort by percent change?</string>
|
||||
<string name="checkout_open_source">Checkout\nhttps://github.com/premnirmal/StockTicker</string>
|
||||
<string name="auto_sort_desc">Stocks will be sorted by percent change in descending order.</string>
|
||||
<string name="checkout_open_source">https://github.com/premnirmal/StockTicker</string>
|
||||
<string name="choose_text_size">Choose a text size</string>
|
||||
<string name="text_size_updated_message">Text size updated</string>
|
||||
<string name="bg_updated_message">Background updated</string>
|
||||
<string name="refresh_updated_message">Refresh interval updated</string>
|
||||
<string name="error_exporting">Error exporting file</string>
|
||||
<string name="ticker_import_success">Tickers imported successfully</string>
|
||||
<string name="ticker_import_fail">Error importing tickers</string>
|
||||
@@ -32,5 +36,32 @@
|
||||
<item>Medium</item>
|
||||
<item>Large</item>
|
||||
</string-array>
|
||||
<string-array name="font_sizes_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="backgrounds">
|
||||
<item>Transparent</item>
|
||||
<item>Translucent</item>
|
||||
</string-array>
|
||||
<string-array name="backgrounds_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="sync_periods">
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
<item>45 minutes</item>
|
||||
<item>1 hour</item>
|
||||
</string-array>
|
||||
<string-array name="sync_periods_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<resources>
|
||||
<string name="title_activity_settings_activity2">Settings</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
<!-- Example General settings -->
|
||||
<string name="pref_header_general">General</string>
|
||||
|
||||
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
||||
<string name="pref_description_social_recommendations">Recommendations for people to contact based on your message
|
||||
history
|
||||
</string>
|
||||
|
||||
<string name="pref_title_display_name">Display name</string>
|
||||
<string name="pref_default_display_name">John Smith</string>
|
||||
|
||||
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
|
||||
<string-array name="pref_example_list_titles">
|
||||
<item>Always</item>
|
||||
<item>When possible</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_example_list_values">
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Example settings for Data & Sync -->
|
||||
<string name="pref_header_data_sync">Data & sync</string>
|
||||
|
||||
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||
<string-array name="pref_sync_frequency_titles">
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>3 hours</item>
|
||||
<item>6 hours</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_sync_frequency_values">
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>180</item>
|
||||
<item>360</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||
|
||||
<!-- Example settings for Notifications -->
|
||||
<string name="pref_header_notifications">Notifications</string>
|
||||
|
||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||
|
||||
<string name="pref_title_ringtone">Ringtone</string>
|
||||
<string name="pref_ringtone_silent">Silent</string>
|
||||
|
||||
<string name="pref_title_vibrate">Vibrate</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ListPreference
|
||||
android:key="com.github.premnirmal.ticker.textsize"
|
||||
android:title="@string/choose_text_size"
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/font_sizes"
|
||||
android:entryValues="@array/font_sizes_values"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null" />
|
||||
|
||||
<ListPreference
|
||||
android:key="WIDGET_BG"
|
||||
android:title="@string/widget_bg"
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/backgrounds"
|
||||
android:entryValues="@array/backgrounds_values"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null" />
|
||||
|
||||
<ListPreference
|
||||
android:key="UPDATE_INTERVAL"
|
||||
android:title="@string/update_interval"
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/sync_periods"
|
||||
android:entryValues="@array/sync_periods_values"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="SETTING_AUTOSORT"
|
||||
android:title="@string/auto_sort"
|
||||
android:summary="@string/auto_sort_desc"
|
||||
android:defaultValue="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user