mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Added ability to log out.
This commit is contained in:
parent
8d096f0410
commit
60db9ba07e
6 changed files with 88 additions and 11 deletions
35
media/android/NewsBlur/res/layout/fragment_logout_dialog.xml
Normal file
35
media/android/NewsBlur/res/layout/fragment_logout_dialog.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_button_okay"
|
||||
style="@style/greenButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/dialog_message"
|
||||
android:text="@string/alert_dialog_ok"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_button_cancel"
|
||||
style="@style/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/dialog_message"
|
||||
android:padding="10dp"
|
||||
android:text="@string/alert_dialog_cancel"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -91,7 +91,7 @@
|
|||
<string name="toast_marked_feed_as_read">Feed marked as read</string>
|
||||
<string name="toast_error_marking_feed_as_read">Error marking feed as read. Check your internet connection.</string>
|
||||
|
||||
<string name="logout_warning"></string>
|
||||
<string name="logout_warning">Are you sure you want to log out?</string>
|
||||
|
||||
<string name="unsorted_folder_name">Unsorted</string>
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.newsblur.activity;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
@ -13,6 +13,7 @@ import com.actionbarsherlock.view.MenuItem;
|
|||
import com.actionbarsherlock.view.Window;
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.FolderListFragment;
|
||||
import com.newsblur.fragment.LogoutDialogFragment;
|
||||
import com.newsblur.fragment.SyncUpdateFragment;
|
||||
import com.newsblur.service.SyncService;
|
||||
import com.newsblur.view.StateToggleButton.StateChangedListener;
|
||||
|
@ -100,6 +101,9 @@ public class Main extends SherlockFragmentActivity implements StateChangedListen
|
|||
Intent intent = new Intent(this, SearchForFeeds.class);
|
||||
startActivityForResult(intent, 0);
|
||||
return true;
|
||||
case R.id.menu_logout:
|
||||
DialogFragment newFragment = new LogoutDialogFragment();
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -115,12 +119,10 @@ public class Main extends SherlockFragmentActivity implements StateChangedListen
|
|||
|
||||
@Override
|
||||
public void changedState(int state) {
|
||||
Log.d(TAG, "State changed");
|
||||
folderFeedList.changeState(state);
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.d(TAG, "Returned okay.");
|
||||
if (resultCode == RESULT_OK) {
|
||||
folderFeedList.hasUpdated();
|
||||
}
|
||||
|
@ -128,7 +130,6 @@ public class Main extends SherlockFragmentActivity implements StateChangedListen
|
|||
|
||||
@Override
|
||||
public void updateAfterSync() {
|
||||
Log.d(TAG, "Finished feed count refresh.");
|
||||
folderFeedList.hasUpdated();
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
menu.findItem(R.id.menu_refresh).setEnabled(true);
|
||||
|
|
|
@ -10,7 +10,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
private final String TEXT = " text";
|
||||
private final String INTEGER = " integer";
|
||||
private final static String TAG = "DatabaseHelper";
|
||||
private final static String DB_NAME = "blur.db";
|
||||
public final static String DB_NAME = "blur.db";
|
||||
private final static int VERSION = 1;
|
||||
|
||||
public BlurDatabase(Context context) {
|
||||
|
@ -133,6 +133,34 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
db.execSQL(SOCIALFEED_STORIES_SQL);
|
||||
db.execSQL(OFFLINE_UPDATE_SQL);
|
||||
}
|
||||
|
||||
public void dropAndRecreateTables() {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String drop = "DROP TABLE IF EXISTS ";
|
||||
db.execSQL(drop + DatabaseConstants.FEED_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.SOCIALFEED_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.FOLDER_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.STORY_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.COMMENT_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.REPLY_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.CLASSIFIER_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.FEED_FOLDER_MAP_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE);
|
||||
db.execSQL(drop + DatabaseConstants.UPDATE_TABLE);
|
||||
|
||||
db.execSQL(FEED_SQL);
|
||||
db.execSQL(SOCIAL_FEED_SQL);
|
||||
db.execSQL(FOLDER_SQL);
|
||||
db.execSQL(STORY_SQL);
|
||||
db.execSQL(COMMENT_SQL);
|
||||
db.execSQL(REPLY_SQL);
|
||||
db.execSQL(CLASSIFIER_SQL);
|
||||
db.execSQL(FEED_FOLDER_SQL);
|
||||
db.execSQL(SOCIALFEED_STORIES_SQL);
|
||||
db.execSQL(OFFLINE_UPDATE_SQL);
|
||||
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int previousVersion, int nextVersion) {
|
||||
|
|
|
@ -207,7 +207,7 @@ public class FeedProvider extends ContentProvider {
|
|||
@Override
|
||||
public boolean onCreate() {
|
||||
Log.d(TAG, "Creating provider and database.");
|
||||
databaseHelper = new BlurDatabase(getContext());
|
||||
databaseHelper = new BlurDatabase(getContext().getApplicationContext());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.Login;
|
||||
import com.newsblur.database.BlurDatabase;
|
||||
import com.newsblur.network.APIManager;
|
||||
import com.newsblur.util.PrefConstants;
|
||||
|
||||
public class LogoutDialogFragment extends DialogFragment {
|
||||
|
||||
protected static final String TAG = "LogoutDialogFragment";
|
||||
private APIManager apiManager;
|
||||
|
||||
@Override
|
||||
|
@ -25,18 +32,24 @@ public class LogoutDialogFragment extends DialogFragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
final String shareString = getResources().getString(R.string.share_newsblur);
|
||||
|
||||
apiManager = new APIManager(getActivity());
|
||||
View v = inflater.inflate(R.layout.fragment_dialog, container, false);
|
||||
View v = inflater.inflate(R.layout.fragment_logout_dialog, container, false);
|
||||
final TextView message = (TextView) v.findViewById(R.id.dialog_message);
|
||||
final EditText comment = (EditText) v.findViewById(R.id.dialog_share_comment);
|
||||
message.setText(getActivity().getResources().getString(R.string.logout_warning));
|
||||
|
||||
Button okayButton = (Button) v.findViewById(R.id.dialog_button_okay);
|
||||
okayButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(final View v) {
|
||||
SharedPreferences preferences = getActivity().getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
preferences.edit().clear().commit();
|
||||
|
||||
BlurDatabase databaseHelper = new BlurDatabase(getActivity().getApplicationContext());
|
||||
databaseHelper.dropAndRecreateTables();
|
||||
|
||||
Intent i = new Intent(getActivity(), Login.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue