removed wizard

This commit is contained in:
Mariotaku Lee 2016-12-13 19:35:25 +08:00
parent a34b576060
commit 22060773f6
23 changed files with 92 additions and 1036 deletions

View File

@ -165,6 +165,7 @@ dependencies {
compile 'com.lnikkila:extendedtouchview:0.1.0'
compile 'com.google.dagger:dagger:2.6.1'
compile 'org.attoparser:attoparser:2.0.1.RELEASE'
compile 'com.getkeepsafe.taptargetview:taptargetview:1.6.0'
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.17'
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.17'
compile 'com.github.mariotaku.SQLiteQB:library:0.9.8'

View File

@ -383,10 +383,6 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".activity.SettingsWizardActivity"
android:label="@string/settings_wizard"
android:theme="@style/Theme.Twidere.NoActionBar"/>
<activity
android:name=".activity.DataExportActivity"
android:label="@string/export_settings"

View File

@ -1,55 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.preference;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.TextView;
import org.mariotaku.twidere.R;
public final class WizardPageHeaderPreference extends Preference {
public WizardPageHeaderPreference(final Context context) {
this(context, null);
}
public WizardPageHeaderPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.preferenceStyle);
}
public WizardPageHeaderPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
setLayoutResource(R.layout.header_wizard_page);
setSelectable(false);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final TextView title = (TextView) holder.findViewById(android.R.id.title);
final TextView summary = (TextView) holder.findViewById(android.R.id.summary);
title.setText(getTitle());
summary.setText(getSummary());
}
}

View File

@ -1,52 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.preference;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.TextView;
import org.mariotaku.twidere.R;
public final class WizardPageNavPreference extends Preference {
public WizardPageNavPreference(final Context context) {
this(context, null);
}
public WizardPageNavPreference(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.preferenceStyle);
}
public WizardPageNavPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
setLayoutResource(R.layout.settings_layout_wizard_page_nav);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final TextView title = (TextView) holder.findViewById(android.R.id.title);
title.setText(getTitle());
}
}

View File

@ -44,6 +44,10 @@ import org.mariotaku.sqliteqb.library.query.SQLCreateTriggerQuery.Event;
import org.mariotaku.sqliteqb.library.query.SQLCreateTriggerQuery.Type;
import org.mariotaku.sqliteqb.library.query.SQLDeleteQuery;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.annotation.CustomTabType;
import org.mariotaku.twidere.model.Tab;
import org.mariotaku.twidere.model.TabValuesCreator;
import org.mariotaku.twidere.model.tab.TabConfiguration;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
import org.mariotaku.twidere.provider.TwidereDataStore.Activities;
import org.mariotaku.twidere.provider.TwidereDataStore.CachedHashtags;
@ -62,6 +66,7 @@ import org.mariotaku.twidere.util.AccountMigratorKt;
import org.mariotaku.twidere.util.TwidereQueryBuilder.ConversationsEntryQueryBuilder;
import org.mariotaku.twidere.util.TwidereQueryBuilder.DirectMessagesQueryBuilder;
import java.io.IOException;
import java.util.HashMap;
import static org.mariotaku.twidere.util.content.DatabaseUpgradeHelper.safeUpgrade;
@ -82,30 +87,70 @@ public final class TwidereSQLiteOpenHelper extends SQLiteOpenHelper implements C
db.execSQL(createTable(Activities.AboutMe.TABLE_NAME, Activities.AboutMe.COLUMNS, Activities.AboutMe.TYPES, true));
db.execSQL(createTable(Activities.ByFriends.TABLE_NAME, Activities.ByFriends.COLUMNS, Activities.ByFriends.TYPES, true));
db.execSQL(createTable(Drafts.TABLE_NAME, Drafts.COLUMNS, Drafts.TYPES, true));
db.setTransactionSuccessful();
db.endTransaction();
db.beginTransaction();
db.execSQL(createTable(CachedUsers.TABLE_NAME, CachedUsers.COLUMNS, CachedUsers.TYPES, true,
createConflictReplaceConstraint(CachedUsers.USER_KEY)));
db.execSQL(createTable(CachedStatuses.TABLE_NAME, CachedStatuses.COLUMNS, CachedStatuses.TYPES, true));
db.execSQL(createTable(CachedTrends.Local.TABLE_NAME, CachedTrends.Local.COLUMNS, CachedTrends.Local.TYPES,
true));
db.execSQL(createTable(CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS, CachedHashtags.TYPES, true));
db.execSQL(createTable(CachedRelationships.TABLE_NAME, CachedRelationships.COLUMNS, CachedRelationships.TYPES, true,
createConflictReplaceConstraint(CachedRelationships.ACCOUNT_KEY, CachedRelationships.USER_KEY)));
db.setTransactionSuccessful();
db.endTransaction();
db.beginTransaction();
db.execSQL(createTable(Filters.Users.TABLE_NAME, Filters.Users.COLUMNS, Filters.Users.TYPES, true));
db.execSQL(createTable(Filters.Keywords.TABLE_NAME, Filters.Keywords.COLUMNS, Filters.Keywords.TYPES, true));
db.execSQL(createTable(Filters.Sources.TABLE_NAME, Filters.Sources.COLUMNS, Filters.Sources.TYPES, true));
db.execSQL(createTable(Filters.Links.TABLE_NAME, Filters.Links.COLUMNS, Filters.Links.TYPES, true));
db.setTransactionSuccessful();
db.endTransaction();
db.beginTransaction();
db.execSQL(createTable(DirectMessages.Inbox.TABLE_NAME, DirectMessages.Inbox.COLUMNS,
DirectMessages.Inbox.TYPES, true));
db.execSQL(createTable(DirectMessages.Outbox.TABLE_NAME, DirectMessages.Outbox.COLUMNS,
DirectMessages.Outbox.TYPES, true));
db.execSQL(createTable(CachedTrends.Local.TABLE_NAME, CachedTrends.Local.COLUMNS, CachedTrends.Local.TYPES,
true));
db.execSQL(createTable(Tabs.TABLE_NAME, Tabs.COLUMNS, Tabs.TYPES, true));
db.execSQL(createTable(SavedSearches.TABLE_NAME, SavedSearches.COLUMNS, SavedSearches.TYPES, true));
db.execSQL(createTable(SearchHistory.TABLE_NAME, SearchHistory.COLUMNS, SearchHistory.TYPES, true));
db.setTransactionSuccessful();
db.endTransaction();
db.beginTransaction();
createViews(db);
createTriggers(db);
createIndices(db);
db.setTransactionSuccessful();
db.endTransaction();
setupDefaultTabs(db);
}
private void setupDefaultTabs(SQLiteDatabase db) {
db.beginTransaction();
@CustomTabType
String[] tabTypes = {CustomTabType.HOME_TIMELINE, CustomTabType.NOTIFICATIONS_TIMELINE,
CustomTabType.TRENDS_SUGGESTIONS, CustomTabType.DIRECT_MESSAGES};
for (int i = 0, j = tabTypes.length; i < j; i++) {
@CustomTabType
final String tabType = tabTypes[i];
final TabConfiguration conf = TabConfiguration.ofType(tabType);
final Tab tab = new Tab();
tab.setType(tabType);
tab.setIcon(conf.getIcon().getPersistentKey());
tab.setPosition(i);
try {
db.insert(Tabs.TABLE_NAME, null, TabValuesCreator.create(tab));
} catch (IOException e) {
// Ignore
}
}
db.setTransactionSuccessful();
db.endTransaction();
}

View File

@ -1,42 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
/**
* Created by mariotaku on 15/6/30.
*/
public class WizardHighlightTextView extends AppCompatTextView {
public WizardHighlightTextView(Context context) {
super(context);
}
public WizardHighlightTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public WizardHighlightTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
}

View File

@ -51,12 +51,16 @@ import android.view.View
import android.view.View.OnClickListener
import android.view.View.OnLongClickListener
import android.view.ViewGroup.MarginLayoutParams
import com.getkeepsafe.taptargetview.TapTarget
import com.getkeepsafe.taptargetview.TapTargetView
import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.activity_home_content.*
import kotlinx.android.synthetic.main.layout_empty_tab_hint.*
import org.mariotaku.abstask.library.AbstractTask
import org.mariotaku.abstask.library.TaskStarter
import org.mariotaku.kpreferences.get
import org.mariotaku.kpreferences.set
import org.mariotaku.ktextension.addOnAccountsUpdatedListenerSafe
import org.mariotaku.ktextension.convert
import org.mariotaku.ktextension.removeOnAccountsUpdatedListenerSafe
@ -68,6 +72,7 @@ import org.mariotaku.twidere.annotation.CustomTabType
import org.mariotaku.twidere.annotation.ReadPositionTag
import org.mariotaku.twidere.constant.KeyboardShortcutConstants
import org.mariotaku.twidere.constant.SharedPreferenceConstants
import org.mariotaku.twidere.constant.drawerTutorialCompleted
import org.mariotaku.twidere.fragment.*
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
@ -310,11 +315,6 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
} else {
notifyAccountsChanged()
}
val intent = intent
if (openSettingsWizard()) {
finish()
return
}
supportRequestWindowFeature(AppCompatDelegate.FEATURE_ACTION_MODE_OVERLAY)
setContentView(R.layout.activity_home)
@ -386,6 +386,8 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
if (Utils.isStreamingEnabled()) {
startService(Intent(this, StreamingService::class.java))
}
openDrawerTutorial()
}
override fun onStart() {
@ -715,10 +717,32 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
homeMenu.openDrawer(GravityCompat.START)
}
private fun openSettingsWizard(): Boolean {
if (preferences.getBoolean(SharedPreferenceConstants.KEY_SETTINGS_WIZARD_COMPLETED, false))
return false
startActivity(Intent(this, SettingsWizardActivity::class.java))
private fun openDrawerTutorial(): Boolean {
if (preferences[drawerTutorialCompleted]) return false
val targetSize = resources.getDimensionPixelSize(R.dimen.element_size_mlarge)
val height = resources.displayMetrics.heightPixels
val listener: TapTargetView.Listener = object : TapTargetView.Listener() {
override fun onTargetClick(view: TapTargetView?) {
if (!homeMenu.isDrawerOpen(GravityCompat.START)) {
homeMenu.openDrawer(GravityCompat.START)
}
super.onTargetClick(view)
}
override fun onTargetDismissed(view: TapTargetView?, userInitiated: Boolean) {
preferences[drawerTutorialCompleted] = true
}
}
val target = Rect(0, 0, targetSize, targetSize)
target.offsetTo(0, height / 2 - targetSize / 2)
TapTargetView.showFor(this, TapTarget.forBounds(target,
getString(R.string.hint_accounts_dashboard_title),
getString(R.string.hint_accounts_dashboard_message))
.apply {
outerCircleColor(R.color.branding_color)
dimColor(android.R.color.black)
}, listener)
return true
}

View File

@ -1,511 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.activity
import android.Manifest
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v7.app.AlertDialog
import android.support.v7.preference.Preference
import android.view.LayoutInflater
import android.view.View
import android.view.View.OnClickListener
import android.view.ViewGroup
import com.afollestad.appthemeengine.Config
import com.afollestad.appthemeengine.util.ATEUtil
import kotlinx.android.synthetic.main.activity_settings_wizard.*
import org.mariotaku.twidere.Constants.*
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.SupportTabsAdapter
import org.mariotaku.twidere.annotation.CustomTabType
import org.mariotaku.twidere.constant.IntentConstants
import org.mariotaku.twidere.fragment.BaseDialogFragment
import org.mariotaku.twidere.fragment.BasePreferenceFragment
import org.mariotaku.twidere.fragment.BaseSupportFragment
import org.mariotaku.twidere.fragment.ProgressDialogFragment
import org.mariotaku.twidere.fragment.wizard.WizardWelcomePageFragment
import org.mariotaku.twidere.model.Tab
import org.mariotaku.twidere.model.TabValuesCreator
import org.mariotaku.twidere.model.tab.TabConfiguration
import org.mariotaku.twidere.preference.WizardPageHeaderPreference
import org.mariotaku.twidere.preference.WizardPageNavPreference
import org.mariotaku.twidere.provider.TwidereDataStore.Tabs
import org.mariotaku.twidere.util.*
import org.mariotaku.twidere.util.content.ContentResolverUtils
class SettingsWizardActivity : BaseActivity() {
private lateinit var adapter: SupportTabsAdapter
private var task: AbsInitialSettingsTask? = null
fun applyInitialSettings() {
if (task?.status == AsyncTask.Status.RUNNING) return
task = InitialSettingsTask(this)
AsyncTaskUtils.executeTask<AbsInitialSettingsTask, Any>(task)
}
fun applyInitialTabSettings() {
if (task?.status == AsyncTask.Status.RUNNING) return
task = InitialTabSettingsTask(this)
AsyncTaskUtils.executeTask<AbsInitialSettingsTask, Any>(task)
}
fun exitWizard() {
val prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
prefs.edit().putBoolean(KEY_SETTINGS_WIZARD_COMPLETED, true).apply()
val intent = Intent(this, HomeActivity::class.java)
intent.putExtra(IntentConstants.EXTRA_OPEN_ACCOUNTS_DRAWER, true)
startActivity(intent)
finish()
}
fun gotoFinishPage() {
val last = adapter.count - 1
viewPager.currentItem = Math.max(last, 0)
}
fun gotoLastPage() {
gotoPage(pageCount - 2)
}
fun gotoNextPage() {
val current = viewPager.currentItem
viewPager.currentItem = TwidereMathUtils.clamp(current + 1, adapter.count - 1, 0)
}
override fun onBackPressed() {
super.onBackPressed()
}
override fun getStatusBarColor(): Int {
if (VALUE_THEME_NAME_DARK == ateKey) return Color.BLACK
return ATEUtil.darkenColor(ThemeUtils.getColorBackground(this))
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
REQUEST_IMPORT_SETTINGS -> {
if (resultCode == Activity.RESULT_OK) {
gotoLastPage()
} else {
gotoNextPage()
}
}
else -> {
}
}
super.onActivityResult(requestCode, resultCode, data)
}
override val themeBackgroundOption: String
get() = ThemeUtils.getThemeBackgroundOption(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings_wizard)
adapter = SupportTabsAdapter(this, supportFragmentManager, null)
viewPager.adapter = adapter
viewPager.isEnabled = false
indicator.setViewPager(viewPager)
indicator.selectedColor = Config.accentColor(this, ateKey)
initPages()
val initialPage = intent.getIntExtra(IntentConstants.EXTRA_PAGE, -1)
if (initialPage != -1) {
viewPager.setCurrentItem(initialPage, false)
}
}
private fun initPages() {
adapter.addTab(cls = WizardWelcomePageFragment::class.java, name = getString(R.string.wizard_page_welcome_title))
adapter.addTab(cls = WizardPageThemeFragment::class.java, name = getString(R.string.theme))
adapter.addTab(cls = WizardPageTabsFragment::class.java, name = getString(R.string.tabs))
adapter.addTab(cls = WizardPageCardsFragment::class.java, name = getString(R.string.cards))
adapter.addTab(cls = WizardPageUsageStatisticsFragment::class.java, name = getString(R.string.usage_statistics))
adapter.addTab(cls = WizardPageHintsFragment::class.java, name = getString(R.string.hints))
adapter.addTab(cls = WizardPageFinishedFragment::class.java, name = getString(R.string.wizard_page_finished_title))
}
private fun openImportSettingsDialog() {
val intent = Intent(this, DataImportActivity::class.java)
startActivityForResult(intent, REQUEST_IMPORT_SETTINGS)
}
abstract class BaseWizardPageFragment : BasePreferenceFragment(), Preference.OnPreferenceClickListener {
fun gotoFinishPage() {
val a = activity
if (a is SettingsWizardActivity) {
a.gotoFinishPage()
}
}
fun gotoLastPage() {
val a = activity
if (a is SettingsWizardActivity) {
a.gotoLastPage()
}
}
open fun gotoNextPage() {
val a = activity
if (a is SettingsWizardActivity) {
a.gotoNextPage()
}
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
val preferenceManager = preferenceManager
preferenceManager.sharedPreferencesName = SHARED_PREFERENCES_NAME
addPreferencesFromResource(preferenceResource)
val context = activity
val wizardHeader = WizardPageHeaderPreference(context)
wizardHeader.setTitle(headerTitle)
wizardHeader.setSummary(headerSummary)
wizardHeader.order = 0
val screen = preferenceScreen
screen.addPreference(wizardHeader)
val nextPageTitle = nextPageTitle
if (nextPageTitle != 0) {
val nextPage = WizardPageNavPreference(context)
nextPage.order = 999
nextPage.key = WIZARD_PREFERENCE_KEY_NEXT_PAGE
nextPage.setTitle(nextPageTitle)
nextPage.onPreferenceClickListener = this
screen.addPreference(nextPage)
}
val listener = Preference.OnPreferenceChangeListener { preference, newValue ->
val extras = preference.extras
if (extras != null && extras.getBoolean(IntentConstants.EXTRA_RESTART_ACTIVITY)) {
(activity as SettingsWizardActivity).restartWithCurrentPage()
return@OnPreferenceChangeListener true
}
true
}
for (i in 0 until screen.preferenceCount) {
screen.getPreference(i).onPreferenceChangeListener = listener
}
}
override fun onPreferenceClick(preference: Preference): Boolean {
if (WIZARD_PREFERENCE_KEY_NEXT_PAGE == preference.key) {
gotoNextPage()
}
return true
}
protected abstract val headerSummary: Int
protected abstract val headerTitle: Int
protected open val nextPageTitle: Int
get() = R.string.next_step
protected abstract val preferenceResource: Int
}
private fun restartWithCurrentPage() {
val intent = intent
intent.putExtra(EXTRA_PAGE, viewPager.currentItem)
setIntent(intent)
recreate()
}
class WizardPageCardsFragment : BaseWizardPageFragment() {
override val headerSummary: Int
get() = R.string.wizard_page_cards_text
override val headerTitle: Int
get() = R.string.cards
override val preferenceResource: Int
get() = R.xml.preferences_cards
}
class WizardPageFinishedFragment : BaseSupportFragment(), OnClickListener {
override fun onClick(v: View) {
val a = activity
if (a is SettingsWizardActivity) {
a.exitWizard()
}
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater!!.inflate(R.layout.fragment_wizard_page_finished, container, false)
view.findViewById(R.id.exit_wizard).setOnClickListener(this)
return view
}
}
class WizardPageUsageStatisticsFragment : BaseWizardPageFragment() {
override val headerSummary: Int
get() = R.string.wizard_page_usage_statistics_text
override val headerTitle: Int
get() = R.string.usage_statistics
override val nextPageTitle: Int
get() = R.string.next_step
override val preferenceResource: Int
get() = R.xml.settings_wizard_page_usage_statistics
}
class WizardPageHintsFragment : BaseWizardPageFragment() {
override val headerSummary: Int
get() = R.string.wizard_page_hints_text
override val headerTitle: Int
get() = R.string.hints
override val nextPageTitle: Int
get() = R.string.finish
override val preferenceResource: Int
get() = R.xml.settings_wizard_page_hints
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
super.gotoNextPage()
}
override fun gotoNextPage() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val permissions = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
requestPermissions(permissions, REQUEST_REQUEST_PERMISSIONS)
} else {
// Try getting location, some custom rom will popup requirement dialog
Utils.getCachedLocation(activity)
super.gotoNextPage()
}
}
}
class WizardPageTabsFragment : BaseWizardPageFragment() {
fun applyInitialTabSettings() {
val a = activity
if (a is SettingsWizardActivity) {
a.applyInitialTabSettings()
}
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
findPreference(WIZARD_PREFERENCE_KEY_EDIT_CUSTOM_TABS).onPreferenceClickListener = this
findPreference(WIZARD_PREFERENCE_KEY_USE_DEFAULTS).onPreferenceClickListener = this
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
REQUEST_CUSTOM_TABS -> if (resultCode != Activity.RESULT_OK) {
TabsUnchangedDialogFragment().show(fragmentManager, "tabs_unchanged")
} else {
gotoNextPage()
}
}
super.onActivityResult(requestCode, resultCode, data)
}
override fun onPreferenceClick(preference: Preference): Boolean {
val key = preference.key
if (WIZARD_PREFERENCE_KEY_EDIT_CUSTOM_TABS == key) {
val intent = Intent(activity, SettingsActivity::class.java)
intent.putExtra(SettingsActivity.EXTRA_INITIAL_TAG, "tabs")
startActivityForResult(intent, REQUEST_CUSTOM_TABS)
} else if (WIZARD_PREFERENCE_KEY_USE_DEFAULTS == key) {
applyInitialTabSettings()
}
return true
}
override val headerSummary: Int
get() = R.string.wizard_page_tabs_text
override val headerTitle: Int
get() = R.string.tabs
override val nextPageTitle: Int
get() = 0
override val preferenceResource: Int
get() = R.xml.settings_wizard_page_tab
class TabsUnchangedDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
override fun onCancel(dialog: DialogInterface?) {
gotoNextPage()
}
override fun onClick(dialog: DialogInterface, which: Int) {
gotoNextPage()
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(activity)
builder.setMessage(R.string.wizard_page_tabs_unchanged_message)
builder.setPositiveButton(android.R.string.ok, this)
return builder.create()
}
private fun gotoNextPage() {
val a = activity
if (a is SettingsWizardActivity) {
a.gotoNextPage()
}
}
}
companion object {
private val REQUEST_CUSTOM_TABS = 1
}
}
class WizardPageThemeFragment : BaseWizardPageFragment(), Preference.OnPreferenceClickListener {
override val headerSummary: Int
get() = R.string.wizard_page_theme_text
override val headerTitle: Int
get() = R.string.theme
override val preferenceResource: Int
get() = R.xml.preferences_theme
}
internal abstract class AbsInitialSettingsTask(protected val activity: SettingsWizardActivity) : AsyncTask<Any, Any, Boolean>() {
override fun doInBackground(vararg params: Any): Boolean {
val resolver = activity.contentResolver
val tabs = CustomTabUtils.getTabs(activity)
if (wasConfigured(tabs)) return true
var i = 0
for (type in DEFAULT_TAB_TYPES) {
val conf = TabConfiguration.ofType(type)!!
val tab = Tab()
tab.type = type
tab.icon = conf.icon.persistentKey
tab.position = i++
tabs.add(tab)
}
for (tab in tabs) {
tab.position = i++
}
resolver.delete(Tabs.CONTENT_URI, null, null)
ContentResolverUtils.bulkInsert(resolver, Tabs.CONTENT_URI, tabs.map(TabValuesCreator::create))
return true
}
protected abstract fun nextStep()
override fun onPostExecute(result: Boolean) {
activity.executeAfterFragmentResumed {
val activity = it as SettingsWizardActivity
val fm = activity.supportFragmentManager
val f = fm.findFragmentByTag(FRAGMENT_TAG) as? DialogFragment
f?.dismiss()
}
nextStep()
}
override fun onPreExecute() {
activity.executeAfterFragmentResumed {
val activity = it as SettingsWizardActivity
ProgressDialogFragment.show(activity.supportFragmentManager, FRAGMENT_TAG).isCancelable = false
}
}
private fun wasConfigured(tabs: List<Tab>): Boolean {
return tabs.find({ tab ->
when (tab.type) {
CustomTabType.HOME_TIMELINE, CustomTabType.NOTIFICATIONS_TIMELINE,
CustomTabType.DIRECT_MESSAGES, CustomTabType.DIRECT_MESSAGES_NEXT ->
return@find true
}
return@find false
}) != null
}
companion object {
private val FRAGMENT_TAG = "initial_settings_dialog"
private val DEFAULT_TAB_TYPES = arrayOf(CustomTabType.HOME_TIMELINE, CustomTabType.NOTIFICATIONS_TIMELINE, CustomTabType.TRENDS_SUGGESTIONS, CustomTabType.DIRECT_MESSAGES)
}
}
internal class InitialSettingsTask(activity: SettingsWizardActivity) : AbsInitialSettingsTask(activity) {
override fun nextStep() {
val activity = activity
activity.gotoPage(activity.pageCount - 3)
}
}
private fun gotoPage(page: Int) {
viewPager.currentItem = TwidereMathUtils.clamp(page, 0, pageCount - 1)
}
private val pageCount: Int
get() = adapter.count
internal class InitialTabSettingsTask(activity: SettingsWizardActivity) : AbsInitialSettingsTask(activity) {
override fun nextStep() {
activity.gotoNextPage()
}
}
companion object {
val WIZARD_PREFERENCE_KEY_NEXT_PAGE = "next_page"
val WIZARD_PREFERENCE_KEY_USE_DEFAULTS = "use_defaults"
val WIZARD_PREFERENCE_KEY_EDIT_CUSTOM_TABS = "edit_custom_tabs"
val WIZARD_PREFERENCE_KEY_IMPORT_SETTINGS = "import_settings"
private val REQUEST_IMPORT_SETTINGS = 201
}
}

View File

@ -7,6 +7,7 @@ import org.mariotaku.kpreferences.*
import org.mariotaku.twidere.Constants.KEY_NO_CLOSE_AFTER_TWEET_SENT
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_ATTACH_PRECISE_LOCATION
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_SETTINGS_WIZARD_COMPLETED
import org.mariotaku.twidere.extension.getNonEmptyString
import org.mariotaku.twidere.model.CustomAPIConfig
import org.mariotaku.twidere.model.account.cred.Credentials
@ -35,6 +36,7 @@ val attachPreciseLocationKey = KBooleanKey(KEY_ATTACH_PRECISE_LOCATION, false)
val noCloseAfterTweetSentKey = KBooleanKey(KEY_NO_CLOSE_AFTER_TWEET_SENT, false)
val loadItemLimitKey = KIntKey(KEY_LOAD_ITEM_LIMIT, DEFAULT_LOAD_ITEM_LIMIT)
val defaultFeatureLastUpdated = KLongKey("default_feature_last_updated", -1)
val drawerTutorialCompleted = KBooleanKey(KEY_SETTINGS_WIZARD_COMPLETED, false)
object defaultAPIConfigKey : KPreferenceKey<CustomAPIConfig> {
override fun contains(preferences: SharedPreferences): Boolean {

View File

@ -1,18 +0,0 @@
package org.mariotaku.twidere.fragment.wizard
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.mariotaku.twidere.R
import org.mariotaku.twidere.fragment.BaseSupportFragment
/**
* Created by mariotaku on 2016/12/13.
*/
class WizardWelcomePageFragment : BaseSupportFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return inflater.inflate(R.layout.fragment_wizard_page_welcome, container, false)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activity.SettingsWizardActivity">
<org.mariotaku.twidere.view.ExtendedViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<org.mariotaku.twidere.view.LinePageIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:padding="@dimen/element_spacing_normal"
app:lineWidth="@dimen/line_indicator_line_width_wizard"
app:strokeWidth="@dimen/line_indicator_stroke_width_wizard"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:text="@string/action_skip"/>
</merge>

View File

@ -60,7 +60,7 @@
android:layout_gravity="center"
android:foreground="?selectableItemBackground"
android:scaleType="centerCrop"
tools:src="@drawable/ic_launcher_web"/>
tools:src="@drawable/ic_profile_image_twidere"/>
<TextView
android:layout_width="wrap_content"
@ -156,13 +156,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:maxLines="1"
app:met_baseColor="?android:textColorPrimary"
app:met_floatingLabel="normal"
app:met_floatingLabelText="@string/name"
app:met_maxCharacters="20"
app:met_primaryColor="?colorAccent"
tools:text="TwidereProject"
android:maxLines="1"/>
tools:text="TwidereProject"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/editDescription"
@ -182,26 +182,26 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPostalAddress"
android:maxLines="1"
app:met_baseColor="?android:textColorPrimary"
app:met_floatingLabel="normal"
app:met_floatingLabelText="@string/location"
app:met_maxCharacters="30"
app:met_primaryColor="?colorAccent"
tools:text="Earth"
android:maxLines="1"/>
tools:text="Earth"/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/editUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textUri"
android:maxLines="1"
app:met_baseColor="?android:textColorPrimary"
app:met_floatingLabel="normal"
app:met_floatingLabelText="@string/url"
app:met_maxCharacters="100"
app:met_primaryColor="?colorAccent"
tools:text="https://github.com/TwidereProject/"
android:maxLines="1"/>
tools:text="https://github.com/TwidereProject/"/>
</LinearLayout>
<Space

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/element_spacing_large"
android:paddingRight="@dimen/element_spacing_large">
<ImageView
android:layout_width="@dimen/icon_size_wizard_large"
android:layout_height="@dimen/icon_size_wizard_large"
android:contentDescription="@string/app_name"
android:padding="@dimen/element_spacing_large"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher_web"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lineSpacingMultiplier="1.25"
android:padding="@dimen/element_spacing_normal"
android:text="@string/wizard_page_finished_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/text_size_wizard_text"
android:textStyle="normal"/>
</LinearLayout>
<FrameLayout
android:id="@+id/exit_wizard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:padding="@dimen/element_spacing_large">
<org.mariotaku.twidere.view.WizardHighlightTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="sans-serif-condensed"
android:tag="text_color|accent_color"
android:text="@android:string/ok"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/text_size_wizard_nav_item"
android:textStyle="bold"
tools:ignore="UnusedAttribute"
android:maxLines="1"/>
</FrameLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,6 +0,0 @@
<?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:orientation="vertical">
</RelativeLayout>

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:dividerVertical"
android:orientation="vertical"
android:showDividers="middle">
<org.mariotaku.twidere.view.WizardHighlightTextView
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_normal"
android:tag="text_color|accent_color"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/text_size_wizard_title"
android:maxLines="1"/>
<TextView
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.25"
android:padding="@dimen/element_spacing_normal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/text_size_wizard_text"
android:textStyle="normal"/>
</LinearLayout>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:padding="@dimen/element_spacing_large"
tools:ignore="Overdraw">
<org.mariotaku.twidere.view.WizardHighlightTextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:ellipsize="end"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:tag="text_color|accent_color"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/text_size_wizard_nav_item"
android:textStyle="bold"
tools:ignore="UnusedAttribute"/>
</FrameLayout>

View File

@ -833,4 +833,6 @@
<string name="message_permission_request_compose_location">Twidere needs location permission for adding location to tweets.</string>
<string name="message_permission_request_save_media">Twidere needs storage permission for saving media.</string>
<string name="message_permission_request_share_media">Twidere needs storage permission for sharing media to some apps.</string>
<string name="hint_accounts_dashboard_title">Accounts dashboard</string>
<string name="hint_accounts_dashboard_message">Swipe from screen edge to open accounts dashboard.</string>
</resources>

View File

@ -17,12 +17,6 @@
<edu.tsinghua.hotmobi.UploadLogsPreferences android:title="@string/report_usage_statistics_now"/>
<Preference android:title="@string/settings_wizard">
<intent
android:targetClass="org.mariotaku.twidere.activity.SettingsWizardActivity"
android:targetPackage="org.mariotaku.twidere"/>
</Preference>
<org.mariotaku.twidere.preference.HiddenSettingEntryPreference android:title="@string/hidden_settings"/>
</PreferenceScreen>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/hints">
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:icon="@drawable/ic_action_location"
android:order="11"
android:summary="@string/wizard_hint_summary_location_requirement"
android:title="@string/wizard_hint_title_location_requirement"/>
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:icon="@drawable/ic_action_storage"
android:order="12"
android:summary="@string/wizard_hint_summary_storage_requirement"
android:title="@string/wizard_hint_title_storage_requirement"/>
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:icon="@drawable/ic_action_accounts"
android:order="13"
android:summary="@string/wizard_hint_compose_select_account"
android:title="@string/select_account"/>
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:icon="@drawable/ic_action_speaker_muted"
android:order="14"
android:summary="@string/wizard_hint_filters"
android:title="@string/filters"/>
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:icon="@drawable/ic_action_refresh"
android:order="15"
android:summary="@string/wizard_hint_rate_limit"
android:title="@string/rate_limit"/>
</PreferenceScreen>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/tabs">
<org.mariotaku.twidere.preference.WizardPageNavPreference
android:key="edit_custom_tabs"
android:order="11"
android:title="@string/edit"/>
<org.mariotaku.twidere.preference.WizardPageNavPreference
android:key="use_defaults"
android:order="12"
android:title="@string/wizard_page_welcome_not_now"/>
</PreferenceScreen>

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/usage_statistics">
<org.mariotaku.twidere.preference.ForegroundColorIconPreference
android:order="11"
android:title="@string/research_hot_mobile">
<intent
android:action="android.intent.action.VIEW"
android:data="http://www.dnext.xyz/"/>
</org.mariotaku.twidere.preference.ForegroundColorIconPreference>
</PreferenceScreen>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress AndroidElementNotAllowed -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/wizard_page_welcome_title">
<org.mariotaku.twidere.preference.WizardPageNavPreference
android:key="next_page"
android:order="11"
android:title="@string/wizard_page_welcome_yes"/>
<org.mariotaku.twidere.preference.WizardPageNavPreference
android:key="use_defaults"
android:order="12"
android:title="@string/wizard_page_welcome_not_now"/>
<org.mariotaku.twidere.preference.WizardPageNavPreference
android:key="import_settings"
android:order="13"
android:title="@string/wizard_page_welcome_import_settings"/>
</PreferenceScreen>