-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: application introduction slides added
- Loading branch information
1 parent
6fbe4f8
commit 9252db4
Showing
28 changed files
with
449 additions
and
23 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
156 changes: 156 additions & 0 deletions
156
app/src/main/java/org/mifos/mobile/ui/activities/IntroductionActivity.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,156 @@ | ||
package org.mifos.mobile.ui.activities; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.viewpager.widget.ViewPager; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
import android.Manifest; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.text.Html; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import org.mifos.mobile.R; | ||
import org.mifos.mobile.api.local.PreferencesHelper; | ||
import org.mifos.mobile.ui.adapters.IntroductionViewPagerAdapter; | ||
import org.mifos.mobile.utils.CheckSelfPermissionAndRequest; | ||
import org.mifos.mobile.utils.Constants; | ||
|
||
public class IntroductionActivity extends AppCompatActivity { | ||
|
||
@BindView(R.id.view_pager) | ||
public ViewPager viewPager; | ||
|
||
@BindView(R.id.layoutDots) | ||
public LinearLayout dotsLayout; | ||
|
||
@BindView(R.id.btn_skip) | ||
public Button btnSkip; | ||
|
||
@BindView(R.id.btn_next) | ||
public Button btnNext; | ||
|
||
private IntroductionViewPagerAdapter myViewPagerAdapter; | ||
private TextView[] dots; | ||
private int[] layouts; | ||
private PreferencesHelper prefs; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_introduction); | ||
ButterKnife.bind(this); | ||
|
||
prefs = new PreferencesHelper(this); | ||
layouts = new int[]{ | ||
R.layout.intro_screen_1, | ||
R.layout.intro_screen_2, | ||
R.layout.intro_screen_3, | ||
R.layout.intro_screen_4}; | ||
|
||
addBottomDots(0); | ||
myViewPagerAdapter = new IntroductionViewPagerAdapter(layouts, this); | ||
viewPager.setAdapter(myViewPagerAdapter); | ||
viewPager.addOnPageChangeListener(viewPagerPageChangeListener); | ||
|
||
btnSkip.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
launchHomeScreen(); | ||
} | ||
}); | ||
btnNext.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
int current = getItem(+1); | ||
if (current < layouts.length) { | ||
if (current == 2 && !CheckSelfPermissionAndRequest | ||
.checkSelfPermission(getApplicationContext(), | ||
Manifest.permission.READ_PHONE_STATE)) { | ||
requestPermission(); | ||
} | ||
viewPager.setCurrentItem(current); | ||
} else { | ||
launchHomeScreen(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
private void addBottomDots(int currentPage) { | ||
int colorInactive = getResources().getColor(R.color.primary); | ||
int colorActive = getResources().getColor(R.color.white); | ||
dots = new TextView[layouts.length]; | ||
|
||
dotsLayout.removeAllViews(); | ||
for (int i = 0; i < dots.length; i++) { | ||
dots[i] = new TextView(this); | ||
dots[i].setText(Html.fromHtml(getString(R.string.dot_string))); | ||
dots[i].setTextSize(35); | ||
dots[i].setTextColor(colorInactive); | ||
dotsLayout.addView(dots[i]); | ||
} | ||
if (dots.length > 0) { | ||
dots[currentPage].setTextColor(colorActive); | ||
} | ||
} | ||
|
||
private int getItem(int i) { | ||
return viewPager.getCurrentItem() + i; | ||
} | ||
|
||
private void launchHomeScreen() { | ||
prefs.putBoolean("check_first_time", false); | ||
startActivity(new Intent(this, LoginActivity.class)); | ||
finish(); | ||
} | ||
|
||
|
||
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager | ||
.OnPageChangeListener() { | ||
@Override | ||
public void onPageSelected(int position) { | ||
addBottomDots(position); | ||
|
||
if (position == layouts.length - 1) { | ||
btnNext.setText(getString(R.string.start)); | ||
btnSkip.setVisibility(View.GONE); | ||
} else if (position == 2 && !CheckSelfPermissionAndRequest | ||
.checkSelfPermission(getApplicationContext(), | ||
Manifest.permission.READ_PHONE_STATE)) { | ||
requestPermission(); | ||
} else { | ||
btnNext.setText(getString(R.string.next)); | ||
btnSkip.setVisibility(View.VISIBLE); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPageScrolled(int arg0, float arg1, int arg2) { } | ||
|
||
@Override | ||
public void onPageScrollStateChanged(int arg0) { } | ||
}; | ||
|
||
|
||
/** | ||
* Uses {@link CheckSelfPermissionAndRequest} to check for runtime permissions | ||
*/ | ||
private void requestPermission() { | ||
CheckSelfPermissionAndRequest.requestPermission( | ||
this, | ||
Manifest.permission.READ_PHONE_STATE, | ||
Constants.PERMISSIONS_REQUEST_READ_PHONE_STATE, | ||
getResources().getString( | ||
R.string.dialog_message_phone_state_permission_denied_prompt), | ||
getResources().getString(R.string. | ||
dialog_message_phone_state_permission_never_ask_again), | ||
Constants.PERMISSIONS_READ_PHONE_STATE_STATUS); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/org/mifos/mobile/ui/adapters/IntroductionViewPagerAdapter.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,45 @@ | ||
package org.mifos.mobile.ui.adapters; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.viewpager.widget.PagerAdapter; | ||
|
||
public class IntroductionViewPagerAdapter extends PagerAdapter { | ||
|
||
private LayoutInflater layoutInflater; | ||
private int[] layouts; | ||
Context context; | ||
|
||
public IntroductionViewPagerAdapter(int[] layoutArray, Context context) { | ||
layouts = layoutArray; | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(ViewGroup container, int position) { | ||
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
View view = layoutInflater.inflate(layouts[position], container, false); | ||
container.addView(view); | ||
return view; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return layouts.length; | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(View view, Object obj) { | ||
return view == obj; | ||
} | ||
|
||
|
||
@Override | ||
public void destroyItem(ViewGroup container, int position, Object object) { | ||
View view = (View) object; | ||
container.removeView(view); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:showIn="@layout/activity_introduction"> | ||
|
||
|
||
<androidx.viewpager.widget.ViewPager | ||
android:id="@+id/view_pager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/layoutDots" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/dots_height" | ||
android:layout_alignParentBottom="true" | ||
android:layout_marginBottom="@dimen/dots_margin_bottom" | ||
android:gravity="center" | ||
android:orientation="horizontal"></LinearLayout> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:alpha=".5" | ||
android:layout_above="@id/layoutDots" | ||
android:background="@android:color/white" /> | ||
|
||
<Button | ||
android:id="@+id/btn_next" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentRight="true" | ||
android:background="@null" | ||
android:text="@string/next" | ||
android:textColor="@android:color/white" /> | ||
|
||
<Button | ||
android:id="@+id/btn_skip" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentLeft="true" | ||
android:background="@null" | ||
android:text="@string/skip" | ||
android:textColor="@android:color/white" /> | ||
|
||
</RelativeLayout> |
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,39 @@ | ||
<?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:background="@color/primary_dark"> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:gravity="center_horizontal" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:layout_width="@dimen/img_width_height" | ||
android:layout_height="@dimen/img_width_height" | ||
android:src="@mipmap/mifos_icon" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/slide_1_title" | ||
android:textColor="@android:color/white" | ||
android:textSize="@dimen/slide_title" | ||
android:textStyle="bold" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
android:paddingLeft="@dimen/desc_padding" | ||
android:paddingRight="@dimen/desc_padding" | ||
android:text="@string/slide_1_desc" | ||
android:textAlignment="center" | ||
android:textColor="@android:color/white" | ||
android:textSize="@dimen/slide_desc" /> | ||
|
||
</LinearLayout> | ||
</RelativeLayout> |
Oops, something went wrong.