purge troublesome half-disabled Wizard, rename menu to "Get Apps..."

When clicking on "Wizard" from the menu, then clicking back, it gets stuck
in a strange back stack purgatory, and then randomly changes the language.
So purge the wizard stuff for now, and add back the parts that are still
needed once that is all figured out.

This also simplifies the refactoring of the Intent handling.
This commit is contained in:
Hans-Christoph Steiner 2015-06-08 15:38:22 -04:00
parent a336a294fb
commit fd23da5237
9 changed files with 9 additions and 287 deletions

View File

@ -81,8 +81,7 @@
/>
<activity android:name="org.torproject.android.ui.wizard.PromoAppsActivity" android:exported="false"/>
<activity android:name="org.torproject.android.ui.wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name="org.torproject.android.ui.PromoAppsActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView android:id="@+id/helpscrollview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,57 +0,0 @@
<?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="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout1"
android:layout_gravity="center_horizontal"
android:background="#000000">
<TextView android:textSize="10pt"
android:textColor="#FFFFFF"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:id="@+id/WizardLocaleTitle"
android:layout_width="wrap_content"
android:fadingEdge="vertical"
android:text="@string/wizard_locale_title"
android:singleLine="true"
android:padding="20px" android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
<TableRow android:layout_margin="10dip" android:id="@+id/TableRow01" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout
android:background="#575757"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="3px">
<TextView android:text="@string/wizard_locale_msg" android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:textSize="8pt" android:id="@+id/WizardTextBody1" android:padding="20dip"></TextView>
<ListView
android:id="@+id/wizard_locale_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
</ListView>
</LinearLayout>
</TableRow>
<TableRow android:background="#000000" android:layout_marginTop="10dip" android:paddingTop="10dip" android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
<Button android:text="@string/btn_next" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>

View File

@ -57,8 +57,8 @@
-->
<item android:id="@+id/menu_wizard"
android:title="@string/menu_wizard"
<item android:id="@+id/menu_promo_apps"
android:title="@string/menu_promo_apps"
android:icon="@drawable/ic_menu_goto"
yourapp:showAsAction="never"

View File

@ -25,7 +25,7 @@
<string name="menu_start">Start</string>
<string name="menu_stop">Stop</string>
<string name="menu_about">About</string>
<string name="menu_wizard">Wizard</string>
<string name="menu_promo_apps">Get apps…</string>
<string name="main_layout_download">Download</string>
<string name="main_layout_upload">Upload</string>
<string name="button_help">Help</string>

View File

@ -14,8 +14,8 @@ import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
import org.torproject.android.ui.wizard.PromoAppsActivity;
import android.annotation.TargetApi;
import android.app.Activity;
@ -32,7 +32,6 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.net.Uri;
import android.net.VpnService;
import android.os.Build;
@ -392,7 +391,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
startActivityForResult(intent, REQUEST_SETTINGS);
}
else if (item.getItemId() == R.id.menu_wizard)
else if (item.getItemId() == R.id.menu_promo_apps)
{
startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class));
@ -653,26 +652,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
}
}
else
{
showWizard = mPrefs.getBoolean("show_wizard",showWizard);
//let's not show the wizard now for new users
if (showWizard)
{
Editor pEdit = mPrefs.edit();
pEdit.putBoolean("show_wizard",false);
pEdit.commit();
showWizard = false;
showAlert(getString(R.string.app_name),getString(R.string.wizard_final_msg),true);
}
}
updateStatus("");
@ -698,19 +677,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
mBtnBridges.setChecked(true);
enableBridges(true);
}
private boolean showWizard = true;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// doLayout();
//updateStatus("");
}
}
/*
* Launch the system activity for Uri viewing with the provided url

View File

@ -1,4 +1,4 @@
package org.torproject.android.ui.wizard;
package org.torproject.android.ui;
import android.app.Activity;
import android.content.Intent;
@ -10,14 +10,12 @@ import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import org.torproject.android.OrbotConstants;
import org.torproject.android.R;
import java.util.List;
public class PromoAppsActivity extends Activity implements OrbotConstants {
@ -42,7 +40,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_tips);
setContentView(R.layout.layout_promo_apps);
stepFive();
@ -169,43 +167,16 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
});
// Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
/*
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivityForResult(new Intent(PromoAppsActivity.this, ChooseLocaleWizardActivity.class), 1);
}
});*/
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//showWizardFinal();
finish();
}
});
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class));
return true;
}
return false;
}
boolean isAppInstalled(PackageManager pm, String packageName) {
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
@ -239,32 +210,4 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
return intent;
}
/*
private void showWizardFinal ()
{
String title = null;
String msg = null;
title = context.getString(R.string.wizard_final);
msg = context.getString(R.string.wizard_final_msg);
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, Orbot.class));
}
};
new AlertDialog.Builder(context)
.setIcon(R.drawable.icon)
.setTitle(title)
.setPositiveButton(R.string.button_close, ocListener)
.setMessage(msg)
.show();
}*/
}

View File

@ -1,108 +0,0 @@
package org.torproject.android.ui.wizard;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import info.guardianproject.util.Languages;
import org.torproject.android.OrbotApp;
import org.torproject.android.OrbotConstants;
import org.torproject.android.R;
import org.torproject.android.service.TorServiceUtils;
import java.util.Locale;
public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
private ListView listLocales;
private String[] localeValues;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_wizard_locale);
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
Button next = ((Button)findViewById(R.id.btnWizard2));
// next.setEnabled(false);
Languages languages = OrbotApp.getLanguages(this);
localeValues = languages.getSupportedLocales();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
languages.getAllNames());
listLocales.setAdapter(adapter);
listLocales.setSelection(0);
listLocales.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
setLocalePref(arg2);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setLocalePref(0);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
}
});
}
private void setLocalePref(int selId)
{
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Configuration config = getResources().getConfiguration();
String lang = localeValues[selId];
Editor pEdit = prefs.edit();
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
pEdit.commit();
Locale locale = null;
if (lang.equals("xx"))
{
locale = Locale.getDefault();
}
else
locale = new Locale(lang);
Locale.setDefault(locale);
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
}