only show help in first run and on request
This commit is contained in:
@@ -27,10 +27,10 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -73,6 +73,22 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private AlertDialog dialog;
|
||||||
|
final String PREFS = "ACardEmulatorPrefs";
|
||||||
|
final String PREF_LASTVERSION = "last version";
|
||||||
|
private static String SAVED_STATUS = "textViewVPCDStatus";
|
||||||
|
|
||||||
|
private void showStartupMessage() {
|
||||||
|
if (dialog == null)
|
||||||
|
dialog = new AlertDialog.Builder(this)
|
||||||
|
.setMessage(R.string.startup_message)
|
||||||
|
.setTitle(R.string.startup_title)
|
||||||
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
}
|
||||||
|
}).create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -81,13 +97,16 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
textViewVPCDStatus = (TextView) findViewById(R.id.textViewLog);
|
textViewVPCDStatus = (TextView) findViewById(R.id.textViewLog);
|
||||||
textViewVPCDStatus.setMovementMethod(new ScrollingMovementMethod());
|
textViewVPCDStatus.setMovementMethod(new ScrollingMovementMethod());
|
||||||
|
SharedPreferences settings = getSharedPreferences(PREFS, 0);
|
||||||
|
if (settings.getInt(PREF_LASTVERSION, 0) != BuildConfig.VERSION_CODE) {
|
||||||
|
showStartupMessage();
|
||||||
|
settings.edit().putInt(PREF_LASTVERSION, BuildConfig.VERSION_CODE).commit();
|
||||||
|
}
|
||||||
|
|
||||||
LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
|
LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(SimulatorService.TAG);
|
intentFilter.addAction(SimulatorService.TAG);
|
||||||
bManager.registerReceiver(bReceiver, intentFilter);
|
bManager.registerReceiver(bReceiver, intentFilter);
|
||||||
|
|
||||||
showStartupMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,29 +139,21 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static String saved_status_key = "textViewVPCDStatus";
|
|
||||||
@Override
|
@Override
|
||||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
textViewVPCDStatus.setText(savedInstanceState.getCharSequence(saved_status_key));
|
textViewVPCDStatus.setText(savedInstanceState.getCharSequence(SAVED_STATUS));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
savedInstanceState.putCharSequence(saved_status_key, textViewVPCDStatus.getText());
|
savedInstanceState.putCharSequence(SAVED_STATUS, textViewVPCDStatus.getText());
|
||||||
super.onSaveInstanceState(savedInstanceState);
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showStartupMessage() {
|
@Override
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
protected void onPause() {
|
||||||
builder.setMessage(R.string.startup_message)
|
if (dialog != null)
|
||||||
.setTitle(R.string.startup_title)
|
dialog.dismiss();
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
super.onPause();
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
}
|
|
||||||
});;
|
|
||||||
AlertDialog dialog = builder.create();
|
|
||||||
dialog.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user