This repository has been archived by the owner on Jan 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
461 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
src/com/duckduckgo/mobile/android/adapters/BannerOnboardingAdapter.java
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
src/com/duckduckgo/mobile/android/adapters/OnboardingAdapter.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/com/duckduckgo/mobile/android/adapters/OnboardingBannerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.duckduckgo.mobile.android.adapters; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.duckduckgo.mobile.android.R; | ||
import com.duckduckgo.mobile.android.util.OnboardingPageConfiguration; | ||
|
||
/** | ||
* Created by fgei on 4/11/17. | ||
*/ | ||
|
||
public class OnboardingBannerAdapter extends PagerAdapter { | ||
|
||
private final OnboardingPageConfiguration[] items; | ||
|
||
public OnboardingBannerAdapter() { | ||
items = new OnboardingPageConfiguration[] { | ||
OnboardingPageConfiguration.getPrivacy(), | ||
OnboardingPageConfiguration.getNoAds(), | ||
OnboardingPageConfiguration.getNoTracking(), | ||
OnboardingPageConfiguration.getRight() | ||
}; | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(ViewGroup container, int position) { | ||
OnboardingPageConfiguration onboardingPageConfiguration = getItem(position); | ||
LayoutInflater inflater = LayoutInflater.from(container.getContext()); | ||
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.viewholder_onboarding, container, false); | ||
populate(root, onboardingPageConfiguration); | ||
container.addView(root); | ||
return root; | ||
} | ||
|
||
@Override | ||
public void destroyItem(ViewGroup container, int position, Object object) { | ||
container.removeView((View) object); | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(View view, Object o) { | ||
return view == o; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return items.length; | ||
} | ||
|
||
public OnboardingPageConfiguration getItem(int position) { | ||
return items[position]; | ||
} | ||
|
||
private void populate(View rootView, OnboardingPageConfiguration onboardingPageConfiguration) { | ||
Context context = rootView.getContext(); | ||
TextView titleTextView = (TextView) rootView.findViewById(R.id.title_text_view); | ||
String title = context.getString(onboardingPageConfiguration.title).replaceAll("\\n", " "); | ||
titleTextView.setText(title); | ||
TextView subtitleTextView = (TextView) rootView.findViewById(R.id.subtitle_text_view); | ||
String subtitle = context.getString(onboardingPageConfiguration.subtitle).replaceAll("\\n", " "); | ||
subtitleTextView.setText(subtitle); | ||
ImageView iconImageView = (ImageView) rootView.findViewById(R.id.icon_image_view); | ||
iconImageView.setImageResource(onboardingPageConfiguration.icon); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/com/duckduckgo/mobile/android/adapters/OnboardingPageAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.duckduckgo.mobile.android.adapters; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.ColorInt; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentPagerAdapter; | ||
import android.support.v4.content.ContextCompat; | ||
|
||
import com.duckduckgo.mobile.android.fragment.OnboardingPageFragment; | ||
import com.duckduckgo.mobile.android.util.OnboardingPageConfiguration; | ||
|
||
/** | ||
* Created by fgei on 4/4/17. | ||
*/ | ||
|
||
public class OnboardingPageAdapter extends FragmentPagerAdapter { | ||
|
||
private final OnboardingPageConfiguration[] items; | ||
private Context context; | ||
|
||
public OnboardingPageAdapter(Context context, FragmentManager fm) { | ||
super(fm); | ||
this.context = context; | ||
items = new OnboardingPageConfiguration[] { | ||
OnboardingPageConfiguration.getPrivacy(), | ||
OnboardingPageConfiguration.getNoAds(), | ||
OnboardingPageConfiguration.getNoTracking(), | ||
OnboardingPageConfiguration.getRight(), | ||
OnboardingPageConfiguration.getFadeOnboarding() | ||
}; | ||
} | ||
|
||
@Override | ||
public Fragment getItem(int position) { | ||
OnboardingPageConfiguration onboardingPageConfiguration = items[position]; | ||
return OnboardingPageFragment.newInstance(onboardingPageConfiguration, position); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return items.length; | ||
} | ||
|
||
@ColorInt | ||
public int getBackgroundColor(int position) { | ||
return ContextCompat.getColor(context, items[position].backgroundColor); | ||
} | ||
} |
Oops, something went wrong.